当我第一次运行应用程序时,它工作正常。但是当我再次运行两次两次,它崩溃。NSRangeException',原因:'*** - [__ NSArrayM objectAtIndex:]:索引5超出空数组的范围'
这是错误..
NSRangeException”,原因: '*** - [__ NSArrayM objectAtIndex:]:索引5超出界限为空数组'
当我第一次运行应用程序时,它工作正常。但是当我再次运行两次两次,它崩溃。NSRangeException',原因:'*** - [__ NSArrayM objectAtIndex:]:索引5超出空数组的范围'
这是错误..
NSRangeException”,原因: '*** - [__ NSArrayM objectAtIndex:]:索引5超出界限为空数组'
原因:您正在访问空数组即将访问索引处的对象。
与
//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! **
你的数组是空的,但你试图访问它中的一个对象。那就是问题所在。
原因更换像所有的地方在你的代码下面
[arrMydata objectAtIndex:indexPath.row];
:根据你的日志,你要访问空数组。只需通过以下代码修复此问题
if (arrMydata.count > inxexPath.row)
sharObj = [arrMydata objectAtIndex:indexPath.row]
'arrMydata'数组似乎是空的。那就是崩溃日志所告诉的。 – GoodSp33d
arrMydata应该分配] init'ed或者它应该有arrayWithCapacity:// somevalue之前添加对象到arrMydata –
@ 2-Stroker我知道,但我找不到解决方案。 –