0

我正在尝试将新单元格插入 _myMusicCollectionView。数据源是 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'

我哪里错了?

4

1 回答 1

-1

正如您在错误原因中看到的那样,您正在访问索引 805306367 处的单元格。这可能意味着SharedAppDelegate.myMusics.count-1是负数或indPath包含错误值。

于 2013-09-26T20:28:04.547 回答