Reputation: 505
.h file
UIImage *ownImg;
@property (nonatomic, retain) UIImage *ownImg;
.m file
In viewWillAppear method:
UIImage *myImage2 = [UIImage imageNamed:@"thumbnail.png"];
self.ownImg = myImage2;
That is a leak in ownImg, anyone know why it leaking?
BTW, what is the different of using self.ownImg and without the self.
Thanks.
Upvotes: 1
Views: 714
Reputation: 2672
Calling
ownImg = myImage2;
is just an assignment that merely sets the pointers. But calling
self.ownImg = myImage;
will call a @synthesized setter that contains a retain. (I assume you have the @synthesize() for the ownImg.)
Because you're using a setter method that retains you'll have to release it somewhere. Try placing that in the override for the unload method, or if a non-nib class place it in the dealloc.
Upvotes: 3