Reputation: 3350
In my PFUser
class every user has a key called twitterId
, which contains their twitter ID. After I obtained the friend list of the currentUser
from Twitter I can't find these values with a Parse query, despite these ID's are assigned to PFUsers.
I don't really understand why this happens, because when I take the first item of the friends
array and use the equalTo
instead of containedIn
it works perfectly.
This is the solution that I want to use, but doesn't works. The array has values, and these values are assigned to other users, therefore I don't have any idea what's wrong. I would really appreciate if somebody could explain me what did I wrong, because it seems correct for me.
- (void) listTwitterFriends:(NSArray *)friends {
PFQuery *queryFriends = [PFUser query];
[queryFriends whereKey:@"twitterId" containedIn:friends];
[queryFriends findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
NSLog(@"OBJECTS AFTER QUERY %@", objects);
}];
}
This is the working version
- (void) listTwitterFriends:(NSArray *)friends {
NSString *devSt = [NSString stringWithFormat:@"%@", friends[0]];
NSLog(@"First friend ID %@", devSt);
PFQuery *queryFriends = [PFUser query];
[queryFriends whereKey:@"twitterId" equalTo: devSt];
[queryFriends findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
NSLog(@"OBJECTS AFTER QUERY %@", objects);
}];
}
Upvotes: 1
Views: 428
Reputation: 147
Ran into the same problem, however seemed like the strings I was adding to the array of strings to compare where mutable, changing
[friends addObject:friend[@"id"]];
to [friends addObject:[friend[@"id"] copy]];
worked for me.
Make sure the array you pass to listTwitterFriends:
contains objects which types match you parse related key value's type, watch out for mutable versions.
Upvotes: 1