I have potential memory leak problem from the UIImage objects. Code is as below. Please help.
UIImage *image = nil; if (x == 0) { image = [UIImage imageWithCGImage:cg1]; } else { image = [UIImage imageWithCGImage:cg2]; } UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; [image release];
I tried to release UIImage object after if-else block, but Xcode warned about "Incorrect decrement of the reference count of an object that is not owned at this point by the caller",
If I remove the [image release], it shows "Potential leak of an object allocated on line ...".
How to solve the problem ?
Thanks.