-2
このコードをSwift 2.3で実行していたのは問題ありませんでした。 Swift 3のコードを更新し始めたときに問題が発生しました。NSURLがSwift 3.0でnilを返す
{
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のプログラミングに非常に新しいですので、私の質問は非常に基本的なことがあり、私は以下のコードを使用するときに私のNSURL
リターンはゼロ。私はグーグルで多くの答えを見つけることができませんでした。スウィフトは
感謝。 –