0

I am trying translate the objective c code bellow to swift, i did so far but i get some error.. any help appreciate.

 dispatch_async(dispatch_get_main_queue(), ^{
        [self.window.rootViewController presentViewController:self.incomingCall animated:YES completion:nil];

in swift version i did in this way but i get an error :

dispatch_async(dispatch_get_main_queue(), { () -> Void in
            // Show the alert
           self.window?.rootViewController?.present(self.iincomingCall(), animated: true, completion: nil)
        })
user7430661
  • 41
  • 2
  • 8
  • What's the error? Which version of Swift? 2 or 3? – rmaddy Jan 24 '17 at 16:28
  • If you are using Swift 3 then see http://stackoverflow.com/questions/37801370/how-do-i-dispatch-sync-dispatch-async-dispatch-after-etc-in-swift-3?rq=1 – rmaddy Jan 24 '17 at 16:29

1 Answers1

2

The swift 3 syntax is

DispatchQueue.main.async {
      //your code
 }
aleberguer
  • 370
  • 5
  • 13
  • should be something like? DispatchQueue.main.async( execute: { self.window?.rootViewController?.present(self.iincomingCall(), animated: true, completion: nil) }) – user7430661 Jan 24 '17 at 16:32