Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ios sharedsession在完成时出错_Ios_Swift_Swift Playground - Fatal编程技术网

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

在学习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 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);

 })