I use performBatchUpdates () to update my collection view, where I am doing a full update, i.e. I delete everything that was in it, and again insert everything. Package updates are performed as part of the Observer , which is bound to NSMutableArray ( bingDataItems ).
cellItems is an array containing the elements that will or will be inserted into the collection view.
Here is the code:
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { cultARunner *_cultARunner = [cultARunner getInstance]; if ( [[_cultARunner bingDataItems] count] ) { [self.collectionView reloadData]; [[self collectionView] performBatchUpdates: ^{ int itemSize = [cellItems count]; NSMutableArray *arrayWithIndexPaths = [NSMutableArray array];
I get this error, but not at all times (why?)
2012-12-16 13:17:59.789 [16807:19703] *** Assertion failure in -[UICollectionViewData indexPathForItemAtGlobalIndex:], /SourceCache/UIKit_Sim/UIKit-2372/UICollectionViewData.m:442 2012-12-16 13:17:59.790 [16807:19703] DEBUG: request for index path for global index 1342177227 when there are only 53 items in the collection view
I checked the only thread that mentioned the same problem: UICollectionView Assertion error , but this is not very clear, i.e. executing [collectionview reloadData] impractical in performBatchUpdates() .
Any suggestions on what might be wrong here?
ios objective-c uicollectionview
DancingJohn Dec 16 '12 at 18:05 2012-12-16 18:05
source share