cmoulton / grokHTMLAndDownloads

Demo code for HTML parsing and download PDF files. See https://grokswift.com/htmlanddownloads/
MIT License
13 stars 5 forks source link

Swift 3 - Alamofire 4 Compatibility & Error in existing code #2

Open mhmmdmz opened 7 years ago

mhmmdmz commented 7 years ago

Any possibility of a Swift 3 / Alamofire compatibility update? I've been stuck at

urlNode.objectForKeyedSubscript("href") as? String

with Error: Downcast from 'String?' to 'String' only unwraps optionals; did you mean to use '!'?

I've no idea how to get around this and believe started after some futile attempts to update cocoa pods that updated Alamofire.

Please help.

SBrod commented 7 years ago

objectForKeyedSubscript seems to be an error from HTMLReader and has to do with the way swift bridges that to Swift3. the error message says to use subscript (after you fix the optional error message). Use urlNode["href"] or urlNode.attributes["href"] // which is what objectForKeyedSubscript would return.