【发布时间】:2017-07-02 01:48:12
【问题描述】:
我有以下函数,我有完成处理程序,但我收到此错误:
Closure use of non-escaping parameter may allow it to escape
这是我的代码:
func makeRequestcompletion(completion:(_ response:Data, _ error:NSError)->Void) {
let urlString = URL(string: "http://someUrl.com")
if let url = urlString {
let task = URLSession.shared.dataTask(with: url, completionHandler: { (data, urlRequestResponse, error) in
completion(data, error) // <-- here is I'm getting the error
})
task.resume()
}
}
非常感谢您的帮助
【问题讨论】:
标签: ios swift xcode8 completionhandler