我尝试将某个键下的值与[PFUser currentUser]值匹配。但是,当我记录下来时,我注意到它列出了所有PFUser属性。如果有某种方法可以查看某个值是否与[PFUser currentUser]匹配?
PFQuery *queryForMatchedLikes = [PFQuery orQueryWithSubqueries:@[firstToUserQuery, secondToUserQuery]];
[queryForMatchedLikes findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
self.matches = [objects mutableCopy];
if ([self.matches count] == 0) {
NSLog(@"No matches yet");
} else {
for (PFObject *match in self.matches) {
if (match[kDDActivityFirstToUserKey] == [PFUser currentUser]) {
NSLog(@"first event");
} else if (match[kDDActivitySecondToUserKey] == [PFUser currentUser]) {
NSLog(@"second event");
}
}
}
}
}];
答案 0 :(得分:0)
我通过找到两个值的objectId来解决这个问题。
PFQuery *queryForMatchedLikes = [PFQuery orQueryWithSubqueries:@[firstToUserQuery, secondToUserQuery]];
[queryForMatchedLikes findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
self.matches = [objects mutableCopy];
if ([self.matches count] == 0) {
NSLog(@"No matches yet");
} else {
for (PFObject *match in self.matches) {
if ([[match[kDDActivityFirstToUserKey] objectId] isEqualToString:[PFUser currentUser].objectId]) {
NSLog(@"first event");
} else if ([[match[kDDActivitySecondToUserKey] objectId] isEqualToString:[PFUser currentUser].objectId]) {
NSLog(@"second event");
}
}
}
}
}];