Reputation: 4198
The image
is an instance of UIImage
. The first line executes with no problems, but the second one gives an EXC_BAD_ACCESS
error at runtime.
NSLog(@"SCALE: %f", image.scale);
NSLog(@"TEST: %@", NSStringFromCGSize(image.size));
I can view the values of size
property in Xcode by mouse-hovering it though.
Can you please help me in understanding what's wrong with it and/or what I might be missing?
Tested on a device and in simulator running iOS 8.
UPD: This is how I'm creating the image:
ALAssetRepresentation *rep = [asset defaultRepresentation];
CGFloat scale = 1.0f;
CGImageRef imageRef = [rep fullResolutionImage];
UIImage *image = [UIImage imageWithCGImage:imageRef scale:scale orientation:(UIImageOrientation)rep.orientation];
CGImageRelease(imageRef);
I just tried to delete the last line CGImageRelease(imageRef);
and it seem to be fixed the problem. But I do need to release the CGImageRef
, since I'm loading very large photos inside a loop and that takes a lot of memory.
Upvotes: 1
Views: 359
Reputation: 4198
So, I figured it out. The problem was that I released a CGImageRef that I didn't own.
CGImageRef imageRef = [rep fullResolutionImage];
If you get a CGImageRef
by calling fullResolutionImage
, you don't own it. Therefore, you don't need to release it yourself neither.
CGImageRelease(imageRef);
Removing the last line fixed the problem for me.
Upvotes: 1