I would like to put up a UICollectionView
of pictures downloaded from a backend provider, and am running the issue where every time my collection view controller is initialized, the required method
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
always returns 0, despite my providing the code [self.profilePicturesStorage count]
. I understand that because I am using a block to populate the self.profilePicturesStorage
property, at the view initialization it will always return 0 (since the block hasn't finished executing) My question is, how do I update CollectionView's numberOfItemsInSection:
method after my block has finished downloading all the pictures?
This is the block that I execute in viewDidLoad
:
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error){
if ([objects count] > 0){
//... Skip additional code that parse out the downloaded objects
[self.profilePicturesStorage addObject:userPicture];
}
}
else {
NSLog(@"There aren't any pictures for the current user");
}
}
}];
Thanks!
[collectionView reloadData]
should be all you need.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments