简体   繁体   中英

parse.com clarification of ACL (object not found for update)

I got the error "Error: object not found for update (Code: 101, Version: 1.2.9)"

I was told that this error "is typically returned when the current user does not have permission to write to the object in question."

Please help me make sure I understand ACL. I have the following code in my delegate:

PFACL *defaultACL = [PFACL ACL];
[defaultACL setPublicReadAccess:YES];
[PFACL setDefaultACL:defaultACL withAccessForCurrentUser:YES];

(1) So does that mean that for any PFObject I create during the current session, only the current user will be able to make changes to that object, unless I specify through a session of the current user other users who are allowed write access?

(2) Which I would do using the following code (from parse documentation)?

PFObject *groupMessage = [PFObject objectWithClassName:@"Message"];

PFACL *groupACL = [PFACL ACL];

// userList is an NSArray with the users we are sending this message to.

for (PFUser *user in userList) {

    [groupACL setReadAccess:YES forUser:user];
    [groupACL setWriteAccess:YES forUser:user];
}

groupMessage.ACL = groupACL;

[groupMessage saveInBackground];

(3) Now suppose I have a brand new PFUser whom I want to be able to edit an existing PFObject during his current session, but who is not included in the ACL for that existing object. How can I enable that user to edit the object? Would I have to use cloud code to add him to the ACL list? A code example would be appreciated.

Thank you.

  1. Yes, the ACL you listed gives the current user write access and global read access. With this ACL, you'd need to explicitly decide who else should have write access.
  2. It sounds like you're looking for the sort of dynamic group evaluation that a role offers you. If you give write permission to a role object, for example an admins role, then all object's permissions will be affected (without additional API calls) when you add or remove users to the role.

Using createWithoutData to set the referenced object helped me to solve this problem.

myObject.put("item", ParseObject.createWithoutData(<SUB CLASS>.class, <Your object item>));
myObject.saveInBackground();

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