我在项目中有一组像这样的图片:
我想把它们全部放入可变数组中,如下所示:
NSMutableArray *imageArray = [[[NSMutableArray alloc] initWithCapacity:36] retain];
for (int i = 0; i < 36; i++) {
UIImage *image = [[UIImage imageNamed:[NSString stringWithFormat:@"quicktour_%d.JPG",i+1]] autorelease];
[imageArray addObject:image];
}
在模拟器中运行正常,但在添加了大约5张图片后,在设备上运行时会崩溃。
这是一个非ARC项目。我查看了此处SO中所有类似的问题,并尝试了发布的解决方案,但我的问题仍然存在。
有人能帮帮我吗?
先感谢您了。
编辑:
以下是控制台输出的崩溃信息:
***** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSArrayM insertObject:atIndex:]: object cannot be nil' * First throw call stack: (0x2f784f4b 0x39bc56af 0x2f6bec81 0x138987 0x31f2c713 0x31f2c6b3 0x31f2c691 0x31f1811f 0x31f2c107 0x31f2bdd9 0x31f26e65 0x31efc79d 0x31efafa3 0x2f750183 0x2f74f653 0x2f74de47 0x2f6b8c27 0x2f6b8a0b 0x343df283 0x31f5c049 0x1f9ab 0x3a0cdab7) libc++abi.dylib: terminating with uncaught exception of type NSException**