Swift 1.2 - 由于信号命令失败:分段错误:11

时间:2015-06-11 13:10:54

标签: xcode swift uialertcontroller uialertaction

我刚刚更新到Xcode 6.3,我不得不更新我的代码,以便与Swift 1.2一起使用。看起来我的所有代码都是最新的,但是,当谈到UIAlertAction时,我的编译器会感到困惑。

enter image description here

var passwordAlert = UIAlertController (title: "Change Password", message: "For security reasons, you can not change your password through the app. We will send an email to " + currentEmail + ". Click 'Send' to continue.", preferredStyle: UIAlertControllerStyle.Alert)

        let standardCancel = UIAlertAction (title: "Dismiss", style: .Cancel, handler: nil)

        let actionSubmit = UIAlertAction (title: "Send", style: UIAlertActionStyle.Default) { (UIAlertAction: action) -> Void in

            PFUser.requestPasswordResetForEmailInBackground(self.currentEmail){
                (success: Bool!, error: NSError!) -> Void in

                if (success == true) {

                    let emailAlert = UIAlertController (title: "Password", message: "An email containing information on how to change your password has been sent to " + self.currentEmail + ". You should receive it from Parse.com within 10 minutes", preferredStyle: UIAlertControllerStyle.Alert)

                    emailAlert.addAction(standardCancel)

                    self.presentViewController(emailAlert, animated: true, completion: nil)
                }

                else {

                    let errorAlert = UIAlertController (title: "Error", message: "There was an error while processing your request. This may be because the email is invalid or the app could not connect to the internet. Please try again.", preferredStyle: UIAlertControllerStyle.Alert)

                    errorAlert.addAction(standardCancel)

                    self.presentViewController(errorAlert, animated: true, completion: nil)
                }
            }
        }

        let actionCancel = UIAlertAction (title: "Cancel", style: .Cancel, handler: nil)

        passwordAlert.addAction(actionSubmit)
        passwordAlert.addAction(actionCancel)

        self.presentViewController(passwordAlert, animated: true, completion: nil)

有什么想法吗?

0 个答案:

没有答案