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

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

    In iOs 9:

    myString = myString.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
    

    Hope it helps

提交回复
热议问题