【发布时间】:2014-05-20 16:49:01
【问题描述】:
我在从解析查询中获得的对象中的指针获取数据时遇到问题。我在查询中使用了包含键,但在从返回的对象数组中获取包含键信息时遇到问题。我创建了一个 for 循环来迭代结果,但不确定如何将它们存储回数组中。下面是我的代码:
- (void) loadUsersPFUserIsFollowing
{
//Retrieving PFUser Curren Users followers and storing in Array
PFQuery *queryFollowingCount = [PFQuery queryWithClassName:@"Activity"];
[queryFollowingCount whereKey:@"type" equalTo:@"follow"];
[queryFollowingCount whereKey:@"fromUser" equalTo:[PFUser currentUser]];
//Access the the user following informatioin
[queryFollowingCount includeKey:@"toUser"];
//[queryFollowingCount setCachePolicy:kPFCachePolicyCacheThenNetwork];
[queryFollowingCount findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
[HUD hide:YES];
if (!error) {
searchResultsArray = [[NSArray alloc] initWithArray:objects];
NSLog(@"%@", objects);
for (PFObject * postObject in objects) {
PFObject *postAuthor = [postObject objectForKey:@"toUser"][@"username"];
NSLog(@"retrieved related Post Author: %@", postAuthor);
}
[self.tableView reloadData];
} else {
NSLog(@"Something went wrong");
NSLog(@"%@", error);
}
}];
}
【问题讨论】:
标签: ios nsarray parse-platform