performSegueWithIdentifier Not Initiating a Segue

Mi implementación del método performSegueWithIdentifier no está iniciando una segue.

He intentado depurar colocando sentencias de printing antes y después del método: imprime antes, pero no después, lo que obviamente indica que el método no funciona, ¿verdad?

class ViewController: UIViewController{ var signupActive = true @IBOutlet weak var username: UITextField! @IBOutlet weak var password: UITextField! var errorMessage = "Please try again later" func displayAlert(title: String, message: String) { let alert = UIAlertController(title: title, message: message, prefernetworkingStyle: UIAlertControllerStyle.Alert) alert.addAction((UIAlertAction(title: "Ok", style: .Default, handler: { (action) -> Void in self.dismissViewControllerAnimated(true, completion: nil) }))) self.presentViewController(alert, animated: true, completion: nil) } @IBAction func signUp(sender: AnyObject) { if username.text == "" || password.text == "" { displayAlert("Error in form", message: "Please enter a username and password") } else { UIApplication.shanetworkingApplication().beginIgnoringInteractionEvents() var errorMessage = "Please try again later" if signupActive == true { var user = PFUser() user.username = username.text user.password = password.text user.signUpInBackgroundWithBlock({ (success, error) -> Void in UIApplication.shanetworkingApplication().endIgnoringInteractionEvents() if error == nil { // Right here and below as well self.performSegueWithIdentifier("login", sender: self) } else { if let errorString = error!.userInfo["error"] as? String { errorMessage = errorString } self.displayAlert("Failed signup", message: errorMessage) } }) } else { PFUser.logInWithUsernameInBackground(username.text!, password: password.text!, block: { (user, error) -> Void in UIApplication.shanetworkingApplication().endIgnoringInteractionEvents() if user != nil { // Here too print("kay") self.performSegueWithIdentifier("login", sender: self) print("yay") } else { if let errorString = error!.userInfo["error"] as? String { errorMessage = errorString } self.displayAlert("Failed login", message: errorMessage) } }) } } } 

Debe ejecutar el segue en el hilo principal ya que actualmente está ejecutando el segue dentro de un bloque.

Para ejecutar su segue en el hilo principal:

 dispatch_async(dispatch_get_main_queue()){ self.performSegueWithIdentifier("login", sender: self) }