I have a quick question about the dealloc() and viewDidUnload() methods. I notice a lot of code examples, people seem to do different things.
Also, I might add that ARC is not an option.
(1) Should I set all the properties to nil in the dealloc() method including IBOutlets. For example, should I release the instance variable [_myArrary release] and also set self.myArrary = nil.
(2) In viewDidUnload, I think I must set all IBOutlets to nil, and also anything that is created in viewDidLoad. However, what about myString, lets say it is intialized in another method after viewDidLoad is called. Should I set that to nil?
If I have some properties declared as such:
@property (nonatomic, retain) IBOutlet UITableViewCell *myTableCell;
@property (nonatomic, retain) IBOutlet UILabel *myLabel;
@property (nonatomic, retain) NSArray *myArrary;
@property (nonatomic, retain) NSString *myString;
I synthesize them as such:
@synthesize myArrary = _myArrary;
@synthesize myTableCell;
@synthesize myLabel;
@synthesize myString;
- (void)viewDidLoad
{
[super viewDidLoad];
_myArrary = [NSArrary alloc] initWithObjects:@"testObject", nil];
}
- (void)viewDidUnload
{
self.myArrary = nil;
self.myTableCell = nil;
self.myLabel = nil;
[super viewDidUnload];
}
- (void)dealloc
{
[_myArray release];
[super dealloc];
}