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!

有帮助吗?

解决方案

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);
    }
}];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top