Do I have to “release” my UI objects that I declared as IBOutlets with property attributes “retain” and “nonatomic”? I ask because I have a UI var declared as so…
@interface MyViewController : UIViewController
{
IBOutlet UILabel *lblStatus;
}
@property (retain, nonatomic) IBOutlet UILabel *lblStatus;
@end
and my dealloc like so…
- (void)dealloc
{
//[lblStatus release];
[super dealloc];
}
and with the lblStatus UI var commented out, Instruments doesn’t seem to detect any leaks when I pop the view off the navigation stack.
Thanks in advance for your help!
Since they’re retained, yes, you are responsible for releasing them. Usually, with view controllers, that should happen in
-viewDidUnload, like so:(Setting the property’s value, with a synthesized
retainaccessor, will release the old value before setting the instance variable to the new value.)