zumzum
zumzum

Reputation: 20158

Parse, can't delete PFObject from iOS app?

I am trying to delete an object my current user (PFUser) points to:

PFObject * objectB = currentUser[@"B"];
[objectB fetchIfNeeded];
BOOL deleted = [objectB delete];
[currentUser @"B"];

deleted is FALSE.

I get an error saying:

Error: object not found for delete (Code: 101, Version: 1.2.19)

Every time I try to do this I check on the server and the "B" object is there, so why is it telling me "object not found..."?

How do I delete an object another object points to? I have a valid reference to "B" from current user right before I try to do this. I go in the data browser, I go to current user and click on B pointer and it takes me to the right object...

Any idea?

Upvotes: 0

Views: 252

Answers (1)

sergio
sergio

Reputation: 69027

When creating your B object, try and use the following ACL:

PFACL *acl = [PFACL ACLWithUser:[PFUser currentUser]];
[acl setPublicReadAccess:YES];
BObject.ACL = acl;

This will give the current user full privileges on B and set read prevailed for all.

When you use

[PFACL ACL]; 

you get an empty ACL, so to say, that you can then further specify using:

[acl setReadAccess:YES forUser:user];
[acl setWriteAccess:YES forUser:user];

giving read/write access to each user individually.

Also have a look at the Parse iOS Dev Guide, it has a very nice introduction to ACLs (search for ACL in the page).

Upvotes: 1

Related Questions