-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工作。 –