SWIFT: Why is “NSURL(string:” returning with Nil, even though it's a valid url in a browser?

后端 未结 4 683
旧巷少年郎
旧巷少年郎 2021-01-13 05:02

The first two example links are working the third one returns NIL.

Why is NSUrl returning nil for such string, even though it\'s a valid url in a browser?

Am

4条回答
  •  野的像风
    2021-01-13 05:35

    Thank you guys for your help. I added these two lines to my code and it works now:

        selectedFeedURL = selectedFeedURL.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
        selectedFeedURL =  selectedFeedURL.stringByReplacingOccurrencesOfString("%09%09", withString:"")
    

提交回复
热议问题