I am using the parse.com backend service for an iOS application, and I have a problem with processing it properly. I need help with the whereKey: matchesKey: inQuery method;
I have this code:
PFQuery *query1 = [PFQuery queryWithClassName:@"Object"];
PFQuery *query2 = [PFQuery queryWithClassName:@"ObjectsRelations"];
[query2 whereKey:@"user" equalTo:[PFUser currentUser]];
[query1 whereKey:@"objectId" matchesKey:@"objectPointer" inQuery:query2];
[query1 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
// No objects
}];
It does not work the way I want. I tried several ways to compare the "objectPointer" key in the "ObjectsRelations" class (which is a pointer to an instance of the Object class) against the actual object in request 1. I do not return any objects because the comparison does not work the way I want, since the key is objectId is just a string, and the objectPointer key is a pointer to an object.
, , , api-, objectId !
PFQuery *query = [PFQuery queryWithClassName:@"Object"];
PFQuery *query2 = [PFQuery queryWithClassName:@"ObjectRelations"];
[query2 whereKey:@"user" equalTo:[PFUser currentUser]];
[query2 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
PFObject *firstObject = [((PFObject*)[objects firstObject]) objectForKey:@"objectPointer"];
[query whereKey:@"objectId" equalTo:firstObject.objectId];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
}];
}];
api-? ?
- - , : ()
[query1 where:SELF matches:@"objectPointer" inQuery:query2];
?