サイトのhtmlを取得しようと
このサイトを目標にこのサイトを見たりしてやってみているのですがどうしてもうまくいきません。
URLSession.shared...の行でエラーが出ます。
エラー
Ambiguous reference to member 'dataTask(with:completionHandler:)
Found this candidate (Foundation.URLSession)
Found this candidate (Foundation.URLSession)
コード
swift
1 let url = NSURL(string: "http://www.weather-forecast.com/locations/Tokyo-1/forecasts/latest") 2 let task = URLSession.shared.dataTask(with: url, completionHandler: { (data, response, error) in 3 if error != nil { 4 5 print(error!.localizedDescription) 6 7 } else { 8 9 do { 10 11 12 } catch { 13 14 print("error") 15 16 } 17 18 19 } 20 21 }) 22 task.resume()
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。