I have two arrays that I need to compare if their IDs are equal. This is how I am currently doing it:
PFQuery *earnedQuery = [PFQuery queryWithClassName:@"EarnedAchievement"];
[earnedQuery whereKey:@"user" equalTo:[PFUser currentUser]];
[earnedQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
for (Achievement *achievement in allAchievements) {
for (PFObject *earnedAchievement in objects) {
if ([achievement.id isEqualToString:earnedAchievement[@"achievmentId"]]) {
//user has earned this achievement
achievement.earned = [NSNumber numberWithBool:YES];
achievement.earnedDate = earnedAchievement[@"earnedOn"];
}
}
}
[context save:&error];
}];
Is there a better or more efficient way to do this outside of the two for
in loops?