A value of type 'DispatchQueue' does not have an asynchronous member '- Swift 3

I just upgraded my xcode8 to Swift 3 and I got this error:

Value of type 'DispatchQueue' has no member 'asynchronously' 

in this line:

  DispatchQueue.main.asynchronously(execute: 

Here's the whole snippet:

  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() } } 

Recently, upgrading to Swift 3 gave me a lot of errors, they are automatically fixed, but this one will not be fixed on its own, and I do not know what to do.

+7
swift swift3 xcode8
source share
1 answer

There is no asynchronously method in the production release of Swift 3 and iOS 10. This is just 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) } 
+17
source share

All Articles