UITextfield 输出到字符串

UITextfield output to string

我不知道如何将文本字段的输出转换为字符串以用于解析密码重置方法。这是我的代码:

@IBAction func resetPassword(sender: AnyObject)
{
    var refreshAlert = UIAlertController(title: "Password Reset", message: "Enter Email To Reset Password", preferredStyle: UIAlertControllerStyle.Alert)

    refreshAlert.addTextFieldWithConfigurationHandler { emailField -> Void in
    //TextField configuration
    emailField.textColor = UIColor.blueColor()
        emailField.placeholder = "Email Address On File"


}

    refreshAlert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in
        println("Handle Ok logic here")

        PFUser.requestPasswordResetForEmailInBackground(" ", target: nil, selector: nil)

    }))

    refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .Default, handler: { (action: UIAlertAction!) in
        println("Handle Cancel Logic here")
    }))

    presentViewController(refreshAlert, animated: true, completion: nil)        
}

我需要它,所以当按下按钮时,无论他们输入什么电子邮件,都会使用他的密码重置方法发送以进行解析。任何帮助都会很棒!!!

您可以使用 UIAlertControllertextFields 属性。

您可以通过两种方式做到这一点:

refreshAlert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in

    var textField = (refreshAlert.textFields as Array<UITextField>)[0]
    PFUser.requestPasswordResetForEmailInBackground(textField.text, target: nil, selector: nil)

}))