在我的应用程序中,当我第一次运行应用程序时,它工作正常。但是当我再次运行 2 两次时,它崩溃了。
这是错误..
NSRangeException',原因:'*** -[__NSArrayM objectAtIndex:]:索引 5 超出空数组的范围'
最佳答案
原因:您正在访问即将访问索引处对象的空数组。
替换下面代码中的所有地方
[arrMydata objectAtIndex:indexPath.row];
与
//1. Positive index ([anArray objectAtIndex:-NUMBERS]) will crash
//2. within the array boundary
if([arrMydata count] > 0 && [arrMydata count] > indexPath.row){
shrObj=[arrMydata objectAtIndex:indexPath.row];
}
else{
//Array is empty,handle as you needed
}
**Here You can see the non software example, which will explain this issue. Good luck! **
关于ios - NSRangeException',原因 : '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds for empty array' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23423473/