- (CGImageRef)createImage
{
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL,
100,
100,
8,
0,
colorSpace,
kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
CGImageRef imageRef = CGBitmapContextCreateImage(context);
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
return imageRef;
}
- (void)someFunction
{
CGImageRef image = [self createImage];
CGImageRelease(image);
}
I get "Potential leak of an object" on "return imageRef;" and "Incorrect decrement of the reference count" on "CGImageRelease(image)".
How do I tell Xcode that "createImage" is a "create" function and that it's passing responsibility of releasing what is returned to the caller?