【发布时间】:2015-06-13 15:01:14
【问题描述】:
我正在使用解析框架,想知道如何查询位于 PFUser 表中的列。
这里是一些示例代码:
//Adds athlete_id column to roster table
PFObject *roster = [PFObject objectWithClassName:@"Roster"];
roster[@"athlete_id"] = answer;
[roster save];
//Adds the rosters objectId to an array (athlete_id) in the User table.
PFUser *currentUser = [PFUser currentUser];
[currentUser addObject:roster.objectId forKey:@"athlete_id"];
[currentUser saveInBackground];
通过上面的代码,最终在名为“athlete_id”的列中的 User 类中获得了一个 objectsID 数组。
我在从 User 类中检索这个数组时遇到了问题。这是我尝试从用户那里获取数组的方式:
FQuery *query = [PFUser query];;
[query whereKey:@"username" equalTo:[PFUser currentUser].username];
[query whereKeyExists:@"athelete_id"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSLog(@"athlete %@", objects);
} else {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
我想为当前用户获取包含在 player_id 列中的数组,但在此查询中对象数组为空。
【问题讨论】:
标签: ios objective-c parse-platform