NSURL URLWithString: is null with non-english accented characters

前端 未结 5 1371
孤独总比滥情好
孤独总比滥情好 2020-11-29 01:48

I have the following string...

NSString *googleSearchString = @\"http://www.google.com/search?q=lyrics+%22Tænder+På+Dig%22+%22Jakob+Sveistrup%22\";
         


        
5条回答
  •  执笔经年
    2020-11-29 02:15

    Use this for SWIFT 4:

    let url = myURLString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
    let myURL = URL(string: url)
    

提交回复
热议问题