Am 19.11.2008 um 10:05 schrieb mmalcolm crawford:

On Nov 18, 2008, at 10:33 AM, Marc Stibane wrote:
Lets forget for a moment that the dealloc never get's called at all on the iPhone
This is simply untrue.

Nope.
Try to set a breakpoint inside the dealloc in the same file as applicationDidFinishLaunching, run your app and press the home button. Never called, and purposely so - the application finishes anyway, so why spend cycles deallocating small blocks one-by-one when you can just throw away all memory the app used in one block...


So why the local var?
3 lines of code instead of 1...
Isn't a main goal of Cocoa to write *less* code?

Because:
Cocoa strongly advocates you use accessor methods to set instance variables(*); You are discouraged from setting instance variables directly anywhere other than in initializers and dealloc(*);

For me, applicationDidFinishLaunching IS an initializer...


On iPhone in particular, you should avoid the use of autorelease.
The latter point in particular means that this alternative:
   self.viewController = [[[UIViewController alloc]
initWithNibName:@"MoveMeView" bundle:[NSBundle mainBundle]] autorelease];
does not follow best practice.
Thus -- almost by a process of elimination -- you're left with the pattern shown in iPhone samples.

I stick with my applicationDidFinishLaunching implementation - 1 line instead of 3. Of cause you're right were it some other method which could be called more than once and not applicationDidFinishLaunching, which is only called once and - as stated above - never paired with dealloc (however, applicationWillTerminate is called).

--

In a world without walls and fences,
   who needs windows and gates?




_______________________________________________

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