I am working on an ios application where in my appDelegate I have:
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { self.api.signInWithToken(emailstring, token: authtokenstring) { (object: AnyObject?, error:String?) in if(object != nil){ self.user = object as? User // go straight to the home view if auth succeeded var rootViewController = self.window!.rootViewController as UINavigationController let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) var homeViewController = mainStoryboard.instantiateViewControllerWithIdentifier("HomeViewController") as HomeViewControllerenter // code here rootViewController.pushViewController(homeViewController, animated: true) } } return true }
api.signInWithToken is an asynchronous call made using Alamofire, and I would like to wait for it to complete before returning true at the end of the func application.
source share