ios sharedsession在完成时出错
在学习iOS sharedSession单例调用和异步调用时,我被这个讨厌的错误阻止了 这是我的密码ios sharedsession在完成时出错,ios,swift,swift-playground,Ios,Swift,Swift Playground,在学习iOS sharedSession单例调用和异步调用时,我被这个讨厌的错误阻止了 这是我的密码 let baseUrl = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/") let forecast = NSURL(string: "47.856223,-122.272590", relativeToURL: baseUrl) let sharedSession = NSURLSession.sharedSession
let baseUrl = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
let forecast = NSURL(string: "47.856223,-122.272590", relativeToURL: baseUrl)
let sharedSession = NSURLSession.sharedSession()
let downloadTask: NSURLSessionDownloadTask =
sharedSession.downloadTaskWithURL( forecast, completionHandler:
{ (loction: <#NSURL!#>, response: <#NSURLResponse!#>, error: <#NSError!#>) -> Void in
println(response);
})
}
您需要添加带有适当变量的占位符
sharedSession.downloadTaskWithURL(forecast , completionHandler:{(location:NSURL!, response:NSURLResponse!, error:NSError!) -> Void in
println(response);
})
那是你真正的密码吗?必须用实际类型替换占位符。
1-expected an identifier to name generic parameter
2- expect parameter type following :
sharedSession.downloadTaskWithURL(forecast , completionHandler:{(location:NSURL!, response:NSURLResponse!, error:NSError!) -> Void in
println(response);
})