Convert String to NSURL is return nil in swift

前端 未结 6 526
你的背包
你的背包 2020-12-01 09:15

I am trying to convert a String to NSURL and my code for that is Below:

var url = \"https://maps.googleapis.com/maps/api/distancema         


        
6条回答
  •  有刺的猬
    2020-12-01 09:28

    as blwinters said, in Swift 3.0 use

    URL(string: urlPath.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)
    

提交回复
热议问题