NSRangeException',原因:'*** – :索引5超出空数组的边界'
在我的应用程序,当我第一次运行的应用程序,它工作正常。但是当我再次运行两次,它崩溃。
这是错误..
NSRangeException',原因:'*** – [__ NSArrayM objectAtIndex:]:索引5超出空数组的边界'
原因:您正在访问空数组即将访问索引处的对象。
replace下面的代码中的所有地方
[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 }
**在这里你可以看到非软件的例子,这将解释这个问题。 祝你好运! **
你的数组是空的,但你试图访问它中的一个对象。 那就是问题所在。
原因:根据你的日志,你试图访问空数组。 只需通过下面的代码修复
if (arrMydata.count > inxexPath.row) sharObj = [arrMydata objectAtIndex:indexPath.row]