Hi I have this in my application : The question is, should I put self.label =nil; in viewDidUnload? If yes, why?
//.h
@interface MyClass
@property (nonatomic, retain) IBOutlet UILabel *label;
@end
//.m
@implementation Myclass
@syntesize label = label_;
- (void)dealloc
{
self.label =nil;
}
@end
Yes, you should set the label property to
nilboth inviewDidUnloadand indealloc.viewDidUnloadis called in low memory situations which enables the app to purge unneeded memory.Not setting it to
nilinviewDidUnloadwill not usually cause a memory leak in, but it will prevent the app from saving memory when needed.