我想更新我的 ViewController 的属性,该属性self.matchedUsers
从我通过块异步运行的查询中获取数据。
然后某个地方当我通过 检索计数时[self.matchedUsers count]
,尽管知道多个对象已添加到我的属性中,但我仍然得到 0。我的问题是,即使我通过块异步检索数据,如何确保我的属性得到更新?谢谢!
更新:
对于上下文,这里是块:
//Way earlier in an initializer:
self.matchedUsers = [[NSMutableArray alloc] init];
//In a method much later
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error){
//Code that updates self.matchedUsers with the NSArray objects
dispatch_async(dispatch_get_main_queue(), ^{
[self.matchedUsers addObjectsFromArray: objects];
});
//Question relates to ensure how property could be updated
}
}];