Okay, so how am I able to access "textField" at the end of the block where it is added? I tried creating a global property called "alertTextField" then set it to the textField in the block so I can access it in the other action but it doesn't seem to be working. Any suggestions?
Thank you!
@IBAction func resendPassword(sender: AnyObject) {
let alertController : UIAlertController = UIAlertController(title: "Forgot Password?", message: "Enter your email", preferredStyle: UIAlertControllerStyle.Alert)
let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
}
alertController.addAction(cancelAction)
alertController.addTextFieldWithConfigurationHandler { (textField) -> Void in
textField == self.alertTextField
textField.delegate = self
textField.placeholder = "Email"
}
let sendAction: UIAlertAction = UIAlertAction(title: "Send", style: UIAlertActionStyle.Default) { action -> Void in
if (self.alertTextField?.text != nil) {
PFUser.requestPasswordResetForEmailInBackground(self.alertTextField!.text)
}
}
alertController.addAction(sendAction)
self.presentViewController(alertController, animated: true, completion: nil)
}