objective c - Why release a property that you've already set to nil? -


here 2 methods in view controller apple tutorial:

- (void)viewdidunload {     self.eventsarray = nil;     self.locationmanager = nil;     self.addbutton = nil; }  - (void)dealloc {     [managedobjectcontext release];     [eventsarray release];     [locationmanager release];     [addbutton release];     [super dealloc]; } 

couldn't dealloc method shortened following? if not, why not?

- (void)dealloc {     [managedobjectcontext release];     [super dealloc]; } 

- (void)viewdidunload not guaranteed called, should release things in dealloc too.

see this question find out when it's called, , should when is.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -