SWIFT + Parse signUpInBackgroundWithBlock no longer works: Xcode 6.3.1

1.6k views Asked by At

I'm using the latest parse code from the parse.com for user.signupInBackgroundWithBlock

user.signUpInBackgroundWithBlock {
            (succeeded: Bool?, error: NSError?) -> Void in
            if let error = error {
                let errorString = error.userInfo?["error"] as? NSString
               self.showAlertWithText(message: "\(error)")
            } else {
                self.performSegueWithIdentifier("createNewUserAndGoToDashboard", sender: self)
            }

I just upgraded to x-code 6.3.1 and it no longer works. This is copied directly from Parse.com, but I'm getting an error on the user.signUp line:

1.0/SIgnUpViewController.swift:48:46: Function signature '(Bool?, NSError?) -> Void' is not compatible with expected type

'@objc_block (Bool, NSError!) -> Void'

any tips?

2

There are 2 answers

0
AustinTheNoob On BEST ANSWER

have you tried it without the "?" after the Bool

user.signUpInBackgroundWithBlock {
            (succeeded: Bool, error: NSError?) -> Void in
            if let error = error {
                let errorString = error.userInfo?["error"] as? NSString
                self.showAlertWithText(message: "\(error)")
            } else {
                self.performSegueWithIdentifier("createNewUserAndGoToDashboard", sender: self) }
0
pessini On

Try this.

user.signUpInBackgroundWithBlock { (returnedResult, returnedError) -> Void in
        if returnedError == nil
        {
            self.dismissViewControllerAnimated(true, completion: nil)
        }
        else
        {
            self.showAlert("There was an error with your sign up", error: returnedError!)
        }
    }