ios - Correctly releasing returned UIImage -


i call following method image display in uiimageview. when done uiimageview release myimageview.image. happy how instruments showing leak of uiimage. how should releasing below instance of uiimage?

-(uiimage *)getimagewithref:(nsstring *)ref {     uiimage *myimage = [[uiimage alloc] initwithcontentsoffile:[nsstring stringwithformat:@"foobar_%@",ref]];     if (myimage == nil) {         myimage = [[uiimage alloc] initwithcontentsoffile:@"foobar_defaultimage"];     }     return myimage; } 

thanks in advance

try using auto-release when return image.

-(uiimage *)getimagewithref:(nsstring *)ref {     uiimage *myimage = [[uiimage alloc] initwithcontentsoffile:[nsstring stringwithformat:@"foobar_%@",ref]];     if (myimage == nil) {         myimage = [[uiimage alloc] initwithcontentsoffile:@"foobar_defaultimage"];     }     return [myimage autorelease]; } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -