這是一個解決方案。您必須小心,因爲可能有許多對象具有密鑰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