开发者

Do I have to "release" my UI objects that I declared as IBOutlets with property attributes "retain" and "nonatomic"?

开发者 https://www.devze.com 2023-01-09 03:49 出处:网络
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...

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开发者_如何学JAVA 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:

- (void)viewDidUnload
{
    self.lblStatus = nil;
    [super viewDidUnload];
}

(Setting the property's value, with a synthesized retain accessor, will release the old value before setting the instance variable to the new value.)

0

精彩评论

暂无评论...
验证码 换一张
取 消