1

Is it possible to save a parse object with an empty column (pointer value)?

In my code, if a user is not logged in, I want to leave "userSubmitted" empty

        var sendReport = PFObject(className:"UserReport")
        sendReport["ReportReason"] = reason
        sendReport["ReportedPhoto"] = reportedPhoto
        if PFUser.currentUser() == nil
        {
            sendReport["UserSubmitted"] = nil
            //sendReport["UserSubmitted"] = ""
        } else {
            sendReport["UserSubmitted"] = PFUser.currentUser()
        }
        sendReport.saveInBackgroundWithBlock {
        [...]
        }

Crashes at sendReport["UserSubmitted"] = nil and sendReport["UserSubmitted"] = ""

[Error]: invalid type for key UserSubmitted, expected *_User, but got string (Code: 111, Version: 1.7.2)

1 Answer 1

1

To unset an attribute, use removeObjectForKey...

sendReport.removeObjectForKey("UserSubmitted")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.