这是一个解决方案。您必须小心,因为可能有许多对象具有密钥Location
并等于The Shop
。这就是解析返回一个对象数组的原因。在这种情况下,我选择数组中的第一个对象并显示它。
PFQuery *query = [PFQuery queryWithClassName:@"Class1"];
[query whereKey:@"Location" equalTo:@"The Shop"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
Label.text = [NSString stringWithFormat:@"%@", [[objects firstObject] objectForKey:@"WHATEVER YOU WANT TO DISPLAY EX. NAME, LOCATION..."]]
} else {
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
欲了解更多信息,请访问https://parse.com/docs/ios/guide