views:

7

answers:

0

I want to learn the right way to alloc an uiimage and release it for memory management. When i use the following code it crashes when deallocating, if i dont use [imager release]; program doesnt crash but it shows a leak for imager. Any ideas for solution?

UIImage *imager = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:s@"nameofimage" ofType:@"jpg"]]; UIImageView *imageView = [[UIImageView alloc] initWithImage:imager];

[imageView release]; [imager release];