0

I am working on an application that will utilize a custom image picker and try as I might, I can not seem to get the application to run quite right. Xcode debugger flags the following "Thread 1: Program recieved signal: "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)]];
}

This is in xcode 4 on the new debugger. Thanks in advance.

2
  • 4
    read the exception again. Either image or [image imageByScalingAndCroppingForSize:] is nil. Most likely your image scaling method doesn't work correctly. Commented May 2, 2011 at 0:19
  • Where is imageByScalingAndCroppingForSize defined? If it's returning nil, you'll get that error. As you will if image is nil. Commented May 2, 2011 at 0:19

1 Answer 1

5

One of those objects is nil. The following code will help you discover which one:

- (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");
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.