在我的应用程序中,当我第一次运行应用程序时,它工作正常.但是当我再次运行2次,它崩溃了.
这是错误..
NSRangeException’,原因:’*** – [__ NSArrayM objectAtIndex:]:索引5超出空数组的边界’
解决方法
原因:您正在访问要在索引处访问对象的Empty数组.
替换下面代码中的所有地方
[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! **