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

后端 未结 4 734
旧巷少年郎
旧巷少年郎 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:27

    You should URL-encode the URL like this:

    selectedFeedUrl = selectedFeedUrl.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)

提交回复
热议问题