我刚刚把我的xcode8更新到了Swift 3,我收到了这个错误:
Value of type 'DispatchQueue' has no member 'asynchronously'在这一行上:
DispatchQueue.main.asynchronously(execute:下面是完整的代码片段:
DispatchQueue.main.asynchronously(execute: {
//Display alert message with confirmation
let myAlert = UIAlertController(title: "Alert", message:messageToDisplay, preferredStyle: UIAlertControllerStyle.Alert);
let okAction = UIAlertAction(title:"OK", style:UIAlertActionStyle.Default){
action in self.dismissViewControllerAnimated(true, completion:nil);
}
myAlert.addAction(okAction)
self.presentViewController(myAlert, animated:true, completion:nil);
});
}
}
catch let error as NSError {
print(error.localizedDescription)
}
}
task.resume()
}
}最近更新到Swift 3给了我很多错误,它们会自动修复,但这个错误不会自己修复,我不知道该怎么办。
发布于 2016-10-03 06:37:12
在Swift 3和iOS 10的生产版本中,没有asynchronously方法。这只是async
DispatchQueue.main.async {
//Display alert message with confirmation
let alert = UIAlertController(title: "Alert", message: messageToDisplay, preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default) { action in
self.dismiss(animated: true)
}
alert.addAction(okAction)
self.present(alert, animated: true)
}https://stackoverflow.com/questions/39821189
复制相似问题