Hi,
Consider this pseudo code...
...
// an image is initialized
UIImage *imagePX = [[UIImage alloc]initWithContentsOfFile:... bla bla
imagePX = [self rotateImage:imagePX]; //A
[self doStuff:imagePX]; //B
then I have the rotateImage method...
- (UIImage*) rotateImage:(UIImage*)source {
... rotate the image... draw on context...
[source drawInRect... bla bla
...
UIImage *rotatedImage = UIGraphicsGetImageFromCurrentImageContext();
return rotatedImage;
}
My question is: imagePX was never released. As the image is passed to the method RotateImage, I thought I could simply release it, after using it on the command [source drawInRect...], as I would return a rotatedImage on the method, but if I do that, the program will crash, because the variable imagePX should exist so line A can evaluate.
My other problem is that the image will be forwarded on B to another routine. So, what's the best way to make it work without losing track of imagePX and leaking?
What's the best approach?
thanks for any help.