Re: Hang when Nib is loaded
Re: Hang when Nib is loaded
- Subject: Re: Hang when Nib is loaded
- From: Scott Ribe <email@hidden>
- Date: Sun, 13 May 2007 13:45:17 -0600
- Thread-topic: Hang when Nib is loaded
> Controller's window field is nil after *successful* Nib load. How can
> I track window pointer from Nib in order to initialize Controller's
> one to make thing go?
Well I see you figured out that the right way was to use file's owner.
However, you still probably should know about the -window method and
overriding the -awakeFromNib method.
1) You have no way of knowing in what order objects in the nib will be
loaded. So when an object in a nib is init'd, other objects may not yet even
exist, much less the pointers to them be init'd. So in your controller's
init method, no, you can't count on seeing the window pointer. Instead, you
put any init code that depends on those kinds of references ("outlets") in
-awakeFromNib.
2) From that you now may be getting the clue that there are multiple stages
in nib loading and init. All objects in the nib are alloc'd and init'd
first, then the outlets are configured with the actual pointer values, then
-awakeFromNib is called on each object. But there's one more twist, some of
this ( I haven't touched Cocoa in Carbon in a couple of years, so I'm being
deliberately vague) is deferred until the -window method of the window
controller is called.
--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 722-0567 voice
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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