Re: earliest code that runs?
Re: earliest code that runs?
- Subject: Re: earliest code that runs?
- From: Glenn Andreas <email@hidden>
- Date: Tue, 27 Jul 2004 21:41:56 -0500
At 6:42 PM -0700 7/27/04, Shawn Erickson wrote:
On Jul 27, 2004, at 6:08 PM, Matt Neuburg wrote:
What's the earliest code that runs as my app starts up? I ask because I ran
into a problem today where a widget's initWithFrame referred to the
standardUserDefaults, but it turned out that the standardUserDefaults had
not yet been initialized because my call to register the baseline defaults,
in a class's +initialize method, had not yet been executed. I guess I was
assuming that a class's +initialize method would be called before any
instance's init method, but no. (I thought that because an example in the
docs seemed to imply it.) So where can I put code such that I can count on
it to be executed earlier than any other code? Thx - m.
You usually defer such stuff until awakeFromNib or
applicationDidFinishLaunching: time, etc.
applicationDidFinishLaunching is very deceptive. If you have a
document based app which opens a blank document, this will be called
_after_ that blank document is created.
If you try to register something that will be needed by that blank
document UI (say, an NSValueTransformer),
applicationDidFinishLaunching is too late.
--
Glenn Andreas email@hidden
mondo blobbo, Cythera, Theldrow, oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
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.