以下は解析クエリです。コレクション ビューにカテゴリを表示しようとしていますが、解析から情報を取得numberOfItemsInSection
する前にメソッドが実行getCategories
されます。numberOfItemsInSection
を使用getCategories _anArrayOfCategories
して、コレクション ビュー内のカテゴリの数を返します。
-(void)getCategories{
[super viewWillAppear:animated]; //calls retrieve messages method below
//get Categories where the class name is Categories
PFQuery *query = [PFQuery queryWithClassName:@"Categories"];
//- (void)selectKeys:(NSArray *)keys
[query selectKeys:@[@"CName"]];
//[query whereKey:@"recipientIds" equalTo:[[PFUser currentUser] objectId]];
[query orderByAscending:@"createdAt"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
else {
_anArrayOfCategories = [[NSArray alloc] initWithArray:objects];
NSLog(@"Test 1: Retrieved %lu Categories", (unsigned long)[_anArrayOfCategories count]);
}
}];
}
助言がありますか?