NSRangeException',原因:'*** - [__ NSArrayM objectAtIndex:]:索引5超出空数组的边界' [英] NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds for empty array'

查看:527
本文介绍了NSRangeException',原因:'*** - [__ NSArrayM objectAtIndex:]:索引5超出空数组的边界'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,当我第一次运行应用程序时,它运行正常。但是当我再次运行2次时,它会崩溃。

in my application when i run app for first time,it work ok.but when i run again 2 two times, it crashes.

这是错误。 。

NSRangeException',原因:'*** - [__ NSArrayM objectAtIndex:]:索引5超出空数组的界限'

NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds for empty array'

推荐答案

原因:您正在访问要在索引处访问对象的空数组。

Reason: You are accessing Empty array about to access object at index.

替换下面代码中的所有地点

replace all places like in your code below

[arrMydata objectAtIndex:indexPath.row];

with

 //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

 }

**这里你可以看到非软件例如,这将解释这个问题。祝你好运! **

这篇关于NSRangeException',原因:'*** - [__ NSArrayM objectAtIndex:]:索引5超出空数组的边界'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆