Swift 3.0 String转utf-8 url

前端之家收集整理的这篇文章主要介绍了Swift 3.0 String转utf-8 url前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

废弃

  1. leturlString="iosamap://navi?sourceApplication=app名&backScheme=iosamap://&lat=\(self.centerLat)&lon=\(self.centerLng)&dev=0&style=2"
  2. leturl=NSURL(string:urlString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!)
最新

let unsafeP=urlString.addingPercentEncoding(withAllowedCharacters: NSCharacterSet(charactersIn:"`#%^{}\"[]|\\<> ").inverted)

UIApplication.shared.open(URL(string:unsafeP!)!,options: [:],

completionHandler: {

(success) in

print("Open \(success)")

})

原文链接:https://www.f2er.com/swift/322218.html

猜你在找的Swift相关文章