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
Post a Comment