在我的应用程序中,我有许多可变数组,我用 int i 填充了一个 for 循环;我 = 0; 我++;该应用程序工作正常,但现在它开始崩溃,出现以下错误:
* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]' * First throw call stack: (0x32bb888f 0x34b5d259 0x32b019db 0xb1f07 0x372a160d 0x32b8ca33 0x32b8c699 0x32b8b26f 0x32b0e4a5 0x32b0e36d 0x32c5b439 0x350edcd5 0xa8e45 0xa8de0)终止称为抛出异常(lldb)
问题是我不知道是哪个数组导致了问题,而且我有超过 12 个数组。所以我不知道如何解决它。我尝试使用 Zombie objects 功能,但它并没有告诉我哪个数组引起了麻烦。
我也无法理解,因为在代码中我首先这样做:
[messagename removeAllObjects];
[messageframe removeAllObjects];
[messagetext removeAllObjects];
[MapViewArray removeAllObjects];
[DeleteButtonArray removeAllObjects];
[DeleteButtonArray removeAllObjects];
[DeleteButtonArray removeAllObjects];
MapViewArray = [[NSMutableArray alloc]init];
messagename = [[NSMutableArray alloc]init];
messageframe = [[NSMutableArray alloc]init];
messagetext = [[NSMutableArray alloc]init];
DeleteButtonArray = [[NSMutableArray alloc]init];
imageArray = [[NSMutableArray alloc]init];
messageframe = [[NSMutableArray alloc]init];
然后我只以这种方式添加对象:
[messagename addObject: textname];
我什至不访问某个索引!