Re: devil of a time with an NSImageView
Re: devil of a time with an NSImageView
- Subject: Re: devil of a time with an NSImageView
- From: Jean-Daniel Dupas <email@hidden>
- Date: Thu, 20 Aug 2009 16:40:28 +0200
Le 20 août 2009 à 16:21, I. Savant a écrit :
On Aug 20, 2009, at 9:37 AM, Jean-Daniel Dupas wrote:
I managed to find a issue when you don't bind the window outlet and
try to call [self window] in awakeFromNib.
Instead of returning nil, it try to load the nib again, falls in a
infinite recursive loop and crash when the stack is full. That is
the problem I encountered.
Huh. Well sending a -window message to a controller with no window
present shouldn't cause the behavior you described, so on its
surface, it sure looks like an API bug, but ...
From the NSNibWaking Protocol Reference:
"An awakeFromNib message is sent to each object loaded from the
archive, but only if it can respond to the message, and only after
all the objects in the archive have been loaded and initialized.
When an object receives an awakeFromNib message, it is guaranteed to
have all its outlet instance variables set."
It also says:
"Important: Because the order in which objects are instantiated
from an archive is not guaranteed, your initialization methods
should not send messages to other objects in the hierarchy."
For the OP's question, it truly depends on from where -loadWindow
is being called, but -awakeFromNib has the final where "is it done
yet" is concerned.
I'm not convinced yet that relying on -loadWindow is as good as
keeping nib-loading-related startup code in -awakeFromNib.
It's fine too.
From the NSWindowController subclass note (at bottom of the reference):
"windowDidLoad : Override to perform tasks after the window nib file
is loaded."
And the -[NSWindowController window] and -[NSWindowController
loadWindow] confirms that windowDidLoad is invoke only when the nib
has finish loading.
_______________________________________________
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