문제

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