2013-09-26 96 views
0

我試圖在_myMusicCollectionView中插入一個新單元格。數據源是SharedAppDelegate.myMusics數組:嘗試插入新單元格時UICollectionView中的NSInternalInconsistencyException

[_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

正如你可以在錯誤的原因閱讀您訪問索引805306367單元格。可能這意味着SharedAppDelegate.myMusics.count-1是否定的或indPath包含錯誤的值。

+0

是的,我明白了。我想知道我應該在哪裏插入新項目,以及何時執行更新? – Burak

相關問題