On Jun 3, 2008, at 2:09 AM, Uli Kusterer wrote:
Am 03.06.2008 um 07:10 schrieb Adam Leonard:
By the way, this shortcut is not just the result of laziness, it is actually faster. Instead of going through all the objects that are used throughout the life span of the app, and having the OS free all of them one at a time, the shortcut lets the OS group all these objects and free them at the same time.

It is, however, perfectly acceptable to override -dealloc in AppController and call [speachSynthesizer release]. I am sure this is discussed elsewhere in the book.

It's not quite that easy: As your first line says, the Cocoa frameworks also take that shortcut. This includes NSApplication, which doesn't release its MainMenu.nib, and instead just relies on the OS to do that when it cleans up the app's whole memory space after it has quit.

So, your app delegate's -dealloc never gets called.

If you really wanted to get rid of this object before quitting, you'd have to do so in -applicationWillTerminate:.

And you'll need to do things this way if you have other resources that you need to clean up; in my case, I needed to cleanly disconnect from a peripheral before quitting, and -applicationWillTerminate: seemed to be the only place where that worked reliably.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to