Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jagatnibas

macrumors regular
Original poster
Jul 28, 2008
126
0
i am doing something like below

Code:
UIImage *img = [UIImage imageNamed:@"a.png"];
UIButton *btn =[[valid instance from nib file]]

[btn setbackgroundImage:img forState:UIControlStateNormal];
[img release];

shouldnot i be able to release img ?
because i dont need the image anymore i ca release img, isn;t it ?

in UIImageView we are able to do that, in button why not ?

like in

Code:
UIImageView = alloc
setImage:img
add subview: imgview
[img release];
[imgview release];
it just works fine !

regards
jagat
 
Go and read the memory management guide: you should not release img as you do not create it with an alloc/init or copy constructor so it is autoreleased.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.