How to prevent Parse from saving PFObject children's?

Viewed 501

I'm facing a very common issue with Parse and iOS.

I have a class POST with the following structure:

  • text(String)
  • Image (PFFile)
  • LikesUsers (Array of String)
  • LikesCount (Int)
  • From (Pointer to User who posted it)

and if the user (already logged in) likes a post. I'm just incrementing the likes and the add Objectid of the user to the array

For example : User-2 likes User-1's Post.

PostObject.incrementKey("Likes")
PostObject.addObject((PFUser.currentUser()?.objectId)!, forKey: "LikesUsers")
PostObject.saveEventually()

The issue is here. I can't save a the PostObject as long as it has a pointer to another user (than the logged in) I'm getting the error :

User cannot be saved unless they have been authenticated via logIn or signUp

So how to prevent from saving the ParseObject Children ("From")

I don't want to use a CloudCode, I want to keep it simple and to Use SaveEventually for a better user experience.

3 Answers
Related