我正在尝试将新单元格插入_myMusicCollectionView。 Datasource是SharedAppDelegate.myMusics数组:
[_myMusicsCollectionView performBatchUpdates:^{
[SharedAppDelegate.myMusics addObject:c.item];
[_myMusicsCollectionView insertItemsAtIndexPaths:[[NSArray alloc] initWithObjects:[NSIndexPath indexPathForRow:SharedAppDelegate.myMusics.count-1 inSection:0], nil]];
} completion:^(BOOL finished) {
[_musicStoreCollectionView reloadItemsAtIndexPaths:[[NSArray alloc] initWithObjects:indPath, nil]];
}];
我得到了:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for index path for global index 805306367 when there are only 1 items in the collection view'
我哪里错了?
答案 0 :(得分:-1)
正如您可以阅读错误原因,您正在访问索引为805306367的单元格。可能这意味着SharedAppDelegate.myMusics.count-1
为负数或indPath
包含错误值。