我目前对parse.com有这个查询:
- (void)viewDidLoad
{
PFQuery *activityQuery = [PFQuery queryWithClassName:@"Activities"];
[activityQuery whereKey:@"triathlete" equalTo:[PFUser currentUser]];
[activityQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
_activityArray = objects;
NSLog(@"activityArray = %@",_activityArray);
}
}];
它存储了我数据库中每个对象的所有数据。我的问题是如何从单个列中获取数据,而不是从一个数组中获取所有数据。
非常感谢
答案 0 :(得分:1)
如果我正确理解了您的问题,您可以在块内的不同数组中分隔列,如下所示:
[activityQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSMutableArray *column1 = [objects valueForKey:@"column1"];
NSMutableArray *column2 = [objects valueForKey:@"column2"];
NSMutableArray *column3 = [objects valueForKey:@"column3"];
}
}];
然后对每个Array
执行任何操作。
答案 1 :(得分:0)
从查询结果中获取单个列使用以下方式
[activityQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
(if!error){
for(PFObject *object in objects){
// to print individual object one by one
NSLog(@"%@",object);
// to retrieve individual column if the column is string type
NSLog(@"%@",[object objectForkey:@"yourColumnName"]);
}
}];