objective c - iPhone Method Questions (dealloc an viewDidUnload) -
i have been working on app, , book read said put these statements viewdidunload , dealloc methods. other information should go here? have buttons , labels in program. need them?
i want efficiently running application.
here's code:
- (void)viewdidunload { // release retained subviews of main view. // e.g. self.myoutlet = nil; self.doublepicker = nil; self.color = nil; self.choice = nil; [super viewdidunload]; } - (void)dealloc { [doublepicker release]; [color release]; [choice release]; [super dealloc]; }
you should release iboutlets , other ui elements in viewdidunload. other data allocated in view controller (as iboutlets) should released in dealloc method. that's because view can loaded , unloaded multiple times during lifetime of view controller. example, view can unloaded if not visible, data behind (in view controller) still needs kept in memory. when both view , controller no longer needed, dealloc method called.
Comments
Post a Comment