gpt4 book ai didi

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

转载 作者:技术小花猫 更新时间:2023-10-29 11:11:45 36 4
gpt4 key购买 nike

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

这是错误..

NSRangeException',原因:'*** -[__NSArrayM objectAtIndex:]:索引 5 超出空数组的范围'

enter image description here

enter image description here

最佳答案

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

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

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

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com