Re: Deallocation in Cocoa [greenhorn]
Re: Deallocation in Cocoa [greenhorn]
- Subject: Re: Deallocation in Cocoa [greenhorn]
- From: David Remahl <email@hidden>
- Date: Mon, 21 Oct 2002 13:54:29 +0200
Maksymilian,
This was discussed in depth about a week ago. The consensus was that, since
the application is terminating, there is no need for the dealloc method to
be called. Dealloc should only free memory, and since all memory allocated
to the program is going to be freed anyway by the OS, the extra deallocation
would just make the termination process take more time. Please correct me
someone if I misrepresent anything.
The other conclusion from the old thread was that any cleanup other than
deallocation of memory, should not be done in dealloc, but somewhere else,
for example as a response to the notification sent when NSApplication is
terminating.
/ Sincerely, David Remahl
>
In nearly all tutorials introducing to Cocoa programming a new controller
>
class (myControler as sublcass of NSObject) is created and instantiated in
>
the MainMenu nib file.
>
>
So I created such controller class in my application. In the dealloc method
>
I put statment:
>
>
NSLog(@"myController dealloc");
>
>
The problem is, the dealloc method is not executed, when the application
>
quits. As a workaround I made myContoller class the delegate of the
>
application and in method (not mentioned in tutorials):
>
>
- (void)applicationWillTerminate:(NSNotification *)aNotification
>
>
I put statement:
>
>
[self release];
>
>
As the result, the dealloc method is launched when the app quits. Is it the
>
proper way to deallocate the main Controller?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.