简体   繁体   中英

iOS swift parse push notification

func singUp() {
    var user = PFUser()

    if ((self.userName.text != "") && (self.password.text != "") && (self.email.text != "") && (self.email.text == self.reenterEmail.text) && (self.gender != "")){

        user.username = "\(userName.text.lowercaseString)"
        self.userName.resignFirstResponder()
        user.password = "\(password.text.lowercaseString)"

        user.email = "\(email.text.lowercaseString)"
        user["gender"] = "\(self.gender)"



        user.signUpInBackgroundWithBlock {
            (succeeded: Bool, error: NSError?) -> Void in
            if let error = error {
                let errorString = error.userInfo?["error"] as? NSString
                self.errorAlert("\(errorString)")

             } else {
                // Hooray! Let them use the app now.

                let message = "We have sent you a link on your email to verify Your account"
                let okText = "Ok"


                let alert = UIAlertController(title: "Signin Up Completed", message: message, preferredStyle: UIAlertControllerStyle.Alert)
                let okayButton = UIAlertAction(title: okText, style: UIAlertActionStyle.Cancel, handler: { action in self.performSegueWithIdentifier("ShowSignInPage", sender: self)})
                alert.addAction(okayButton)
                self.presentViewController(alert, animated: true, completion: nil)

                let installation = PFInstallation.currentInstallation()
                installation["user"] = self.userName.text.lowercaseString
                installation.saveInBackground()

            }
        }

I'm having a problem with the installation class, where user's information is not saved in this class. I'm getting this error:

[Error]: object not found for update (Code: 101, Version: 1.7.5) 

I think you problem is in this line :

if let error = error 

you should change it to :

if error != nil {}

Thats should be it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM