Re: app delegate +initialize
Re: app delegate +initialize
- Subject: Re: app delegate +initialize
- From: John Baldwin <email@hidden>
- Date: Wed, 7 Oct 2009 20:39:20 -0700
Perhaps that's what's tripping me up: bogus expectations. Here's what
I have set up.
In the xib file, the File's Owner delegate is set to an AppController
instance (an object in the xib).
The AppController has a +initialize method which initializes my user
defaults.
Inside the xib is a window which is set to visible at launch. The
error happens in the window controller for this window, which is
expecting the user defaults to be initialized by the AppController
instance.
So I'm expecting the AppController instance to be loaded and the
+initialize method to be called before my window controller is loaded
and its outlets start getting referenced.
John
On Wednesday Oct 7 10:48 AM, at 10:48 AM, Jens Alfke wrote:
On Oct 6, 2009, at 11:30 PM, John Baldwin wrote:
When the application crashes on launch, there is no record of the
+initialize method being called. When the application launches
successfully, there is a record of the +initialize method being
called.
I haven't been following the whole thread, but are you assuming that
all classes are initialized immediately when the process launches
(similar to C++ static initializers)? Because that isn't the way it
works. A class isn't initialized until the first time it's used — by
creating an instance, calling a class method, or looking up the
class by name.
So it's entirely possible that something unrelated to this class is
causing a crash before that class ever gets referenced. Are you able
to get a backtrace or crash log?
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden