Domanda

I'm using iOS.

If I insert @"objectId" in the whereKey:@"". I get an error saying: bad special key: objectId.

This is my code:

PFQuery *findFriends = [PFUser query];
[findFriends whereKey:@"objectId" equalTo:friendsID];
[findFriends selectKeys:@[@"firstname",@"lastname"]];
[findFriends findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (!error) {
        NSLog(@"%@", objects);
    }
}];

friendsID is an NSString with the objectId from the user the current user is following.

Thank you!

È stato utile?

Soluzione

The problem is that your friendsID is not actually a string, my guess is that it's a PFUser. If this is the case, then one way to do it would be to user this.

PFUser * toUser = [friends[0] objectForKey:@"toUser"];
PFQuery * findFriends = [PFUser query];
[findFriends whereKey:@"objectId" equalTo:toUser.objectId];
[findFriends selectKeys:@[@"firstname",@"lastname"]];
[findFriends findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (!error) {
        NSLog(@"%@", objects);
    }
}];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top