我正在开发一个将使用自定义图像选择器的应用程序,尽我所能尝试,我似乎无法让该应用程序正常运行。 Xcode 调试器标记以下“线程 1:程序收到信号:“SIGABRT”。”
- (id) init {
if ((self = [super init])) {
_images = [[NSMutableArray alloc] init];
_thumbs = [[NSMutableArray alloc] init];
}
return self;
}
- (void)addImage:(UIImage *)image {
[_images addObject:image];
[_thumbs addObject:[image imageByScalingAndCroppingForSize:CGSizeMake(64, 64)]];
}
这是在新调试器上的 xcode 4 中。 提前致谢。
最佳答案
其中一个对象是 nil。以下代码将帮助您发现是哪一个:
- (void)addImage:(UIImage *)image
{
if (image)
{
[_images addObject:image];
}
else
{
NSLog(@"image is nil");
}
UIImage *newImage = [image imageByScalingAndCroppingForSize:CGSizeMake(64, 64)];
if (newImage)
{
[_thumbs addObject:newImage];
}
else
{
NSLog(@"newImage is nil");
}
}
关于ios - 模拟器崩溃 "[NSMutableArray insertObject:atIndex:]: attempt to insert nil object at 0'”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5852387/