UITableView insertSections上的应用程序崩溃:*** - [__ NSArrayM objectAtIndex:]:超出边界的索引10 [0 .. 9]

时间:2017-01-24 10:20:54

标签: ios uitableview

我有一个分页,我按以下方式向UITableView添加新的部分:

/* 
Update my datasource by adding required number of new objects to NSMutableArray 
*/
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(startIndex, totalNewSections)];
[myTableView beginUpdates];
[myTableView insertSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
[myTableView endUpdates];

该应用在[ordersTableView endUpdates];行上随机崩溃,错误:

  

*由于未捕获的异常'NSRangeException'而终止应用程序,原因:'* - [__ NSArrayM objectAtIndex:]:索引11超出边界[0   .. 10]'

此外,我已检查[self numberOfSectionsInTableView:myTableView]startIndex + totalNewSections相同。所以,那里没有错误。

编辑: 我相应地更新了我的NSMutableArray数据源。它需要多少个对象。

0 个答案:

没有答案