我有 2 个 NSMutableArrays,我想将某些对象从 1 数组放入另一个数组,我已经编写了代码,但它不起作用,它给了我这个错误: * 由于未捕获的异常 'NSRangeException' 而终止应用程序,原因:'* - [__NSArrayM objectAtIndex:]: index 296 beyond bounds [0 .. 295]' * First throw call stack: (0x1c9a012 0x10d7e7e 0x1c3c0b4 0x2f04 0xb20b90 0x1c59376 0x1c58e06 0x1c40a82 0x1c3ff44 0x1c3fe1b 0x1bf47e3 0x1bf4668 0x1f65c 0x252d 0x2455) libc++abi.dylib: terminate called throwing一个例外
在 viewdidload 中初始化:
arrayLine1 =[[NSMutableArray alloc] initWithCapacity:80000];
arrayLine1a =[[NSMutableArray alloc] initWithCapacity:70000];
line1tagzahl=0;
line1tagzahl2=0;
传递代码:
for (int a=0; a<10; ) {
[arrayLine1a insertObject:[arrayLine1 objectAtIndex:line1tagzahl2] atIndex:line1tagzahl2];
line1tagzahl2=line1tagzahl2+1;
a=a+1;
}
在数组中创建对象的函数(此函数调用非常快速且频繁):
for (float a=0; a<0.8; ) {
UIImageView *line1 =[[UIImageView alloc] initWithFrame:CGRectMake(Startpoint1.center.x-(w/2),Startpoint1.center.y-kurve1yf+a,w,h)];
line1.image=[UIImage imageNamed:@"Unbenannt"];
line1.tag=line1tagzahl;
[self.view addSubview:line1];
[arrayLine1 insertObject:line1 atIndex:line1tagzahl];
line1tagzahl=line1tagzahl+1;
a=a+0.1;
}
现在你应该有更多的信息