Re: Question about poseAsClass
Re: Question about poseAsClass
- Subject: Re: Question about poseAsClass
- From: "b.bum" <email@hidden>
- Date: Tue, 12 Aug 2003 13:46:59 -0400
On Monday, August 11, 2003, at 17:44, Tom Sutcliffe <email@hidden>
wrote:
My question is when [MyWindowFix poseAsClass:[NSWindow class] should be
called.
As early as possible. Either in a +load method or in main(). In any
case, it needs to be called before any NSWindow instances are created.
I tried putting it in my applicationWillFinishLaunching method. However
it doesn't work properly and for some reason the app thinks all its
windows are closed (and therefore terminates) when I close the drawer.
Too late -- the NIB is already loaded at that time and windows have
likely already been instantiated from the NIB loading or to display the
app icon.
Then I moved it into my app delegate's +initialize method. Same
problem.
App delegate's +initialize will happen as the NIB loads when the
delegate's class is referenced. Too late.
Then I moved it even earlier in the call sequence, into +load. Now
everything works perfectly.
Makes sense. +load happens as soon as the class is introduced into the
runtime. +load is special; you can have five categories to NSString,
each with their own +load and all five +load implementations will be
invoked!
I know poseAsClass says "The poseAsClass: message should be sent before
any messages are sent to aClass and before any instances of aClass are
created." which I'm assuming is the root of my problem. Can I rely on
my app delegate's +load method being called before any NSWindows are
created (or before whatever is done that causes the strange bug)?
Yes. See above. But why not push the code into the NSWindowFix class?
I.e. implement +load in that class. As long as the class is linked
into the runtime -- which it is unless you are doing something goofy
with bundles and dynamic loading -- then the +load will work and your
fix will then be universal to all apps by simply adding the
NSWindowFix.[hm] files to a project.
If not, where should I put the pose call? I tried putting it in main.m
which also works but I'd be interested in other people's views on this.
main() will happen before NIB loading -- will work -- but will happen
after +load.
See above for the best location (IMO).
Out of interest, does anyone have any idea why this bug is occurring?
The app doesn't crash and the proper appShouldTerminate sequence is
followed. And when my redefinition of [NSWindow close] merely calls
[super close] and nothing else I still get this strange quitting
problem.
No idea, but make sure you file a bug with
http://bugreport.apple.com.
Even if it has been filed before, the # of duplicates are used as a
voting mechanism to help prioritize bugs.
b.bum
_______________________________________________
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.