self.matchedUsers
ブロックを介して非同期に実行するクエリからデータを取得するViewController のプロパティを更新したいと思います。
それからどこかで を介してカウントを取得すると[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
}
}];