-2
在Swift 2.3中運行此代碼時,它很好。當我開始更新Swift 3的代碼時,問題就開始了。我NSURL
返回零,當我使用下面的代碼:NSURL以Swift 3.0返回零。
{
var searchResults: [String]!
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let correctedAddress = self.searchResults[indexPath.row].addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed)
let urlpath:NSString! = "https://maps.googleapis.com/maps/api/geocode/json?address=\(correctedAddress)" as NSString!
let url = NSURL.init(string: urlpath as String)
}
}
我很新到iOS編程,所以我的問題可能是很基本的。我GOOGLE了很多,但無法找到答案。
感謝Ajay.it工作。 –