Should this variable release manually?
Memory need to be release for alloc, retain and copy. My q开发者_开发百科uestion is for following situation where I retain the UIImage property, but it was autorelease by the function of imagedNamed. Should I still release following variable?
@property (nonatomic, retain) UIImage *image;
self.image = [UIImage imageNamed:@"image.png"];
Thanks!
In your code you don't use your property but assign autoreleased UIImage object to your iVar directly, so you need
retain your image (or better actually use property) - otherwise your image object will be destroyed when you exit current scope and accessing it in other methods will result in an error. So use:
self.image = [UIImage imageNamed:@"image.png"];
Release your image in dealloc method
Yes you have to release image since you retained it.
精彩评论