waitUntilAllTasksAreFinished error Swift
Your checkLogin
function is being called on another thread, so you need to switch back to the main thread before you can call self.performSegueWithIdentifier
. I prefer to use NSOperationQueue
:
func checkLogin(succeed: Bool, msg: String) { if (succeed) { NSOperationQueue.mainQueue().addOperationWithBlock { self.performSegueWithIdentifier("logInTrue", sender: self) } }}
Alternate: xCode 10.1 1/2019
func checkLogin(succeed: Bool, msg: String) { if (succeed) { OperationQueue.main.addOperation { self.performSegue(withIdentifier: "logInTrue", sender: self) } } }
I was also having same issue, got resolved by taking reference from above answer. Thank you @Nate
var storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)var vc: UINavigationController = storyBoard.instantiateViewControllerWithIdentifier("AppViewController") as! UINavigationControllerNSOperationQueue.mainQueue().addOperationWithBlock { self.presentViewController(vc, animated: true, completion: nil)}