Create a User with Profile Picture with Parse in Swift

1.8k views Asked by At

How would I create a sign up page using Parse where I could also get the user to input there own profile picture in Swift.

1

There are 1 answers

0
Santu C On BEST ANSWER

Please check below code , add a photo fields into your user table with parse.com

 var user = PFUser()

    let imageData = UIImageJPEGRepresentation(userDetails.getPhoto(), 0.05)
    let imageFile = PFFile(name:"image.jpg", data:imageData)
    imageFile.save()

    user.username = usrEntered
    user.password = pwdEntered
    user.email = emlEntered

    user.setObject(imageFile, forKey: "photo")

    user.signUpInBackgroundWithBlock {
        (succeeded: Bool!, error: NSError!) -> Void in
            if error == nil {
               // Hooray! Let them use the app now.
               self.messageLabel.text = "User Signed Up";
            } else {
                // Show the errorString somewhere and let the user try again.
            }
    }