I have a parse object that I need to query based on a PFRelation property. I need to query for all objects in which the relation is empty and all objects in which the relation is not empty. What's the best approach for this? I'm using the iOS SDK.
Asked
Active
Viewed 221 times
1 Answers
-1
PFUser * currentUser = [PFUser currentUser];
PFRelation *relation = [currentUser relationForKey:@"habits"];
PFObject *object = [PFObject objectWithClassName:@"Habit"];
object[@"name"] = @"gym";
[object saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
[relation addObject:object];
[currentUser saveInBackground];
}
}];

Kamalkumar.E
- 254
- 2
- 11
-
this doesn't answer the question – Julien Altieri Jun 21 '17 at 22:19
-
i tried with above sample it's worked for me.to object relation between two class in parse. (Note:Parse had stopped their service) – Kamalkumar.E Jun 22 '17 at 16:21
-
He is asking how to query a class based on the emptiness or not of a relation. Your sample code is about adding something to an object's relation. I still haven't found a good solution for this. – Julien Altieri Jun 23 '17 at 19:09