Re: If the NIB instantiates everything how does the controller get a reference to the View and the Model?
Re: If the NIB instantiates everything how does the controller get a reference to the View and the Model?
- Subject: Re: If the NIB instantiates everything how does the controller get a reference to the View and the Model?
- From: Ken Thomases <email@hidden>
- Date: Mon, 27 Oct 2008 21:06:54 -0500
On Oct 27, 2008, at 8:48 PM, Michael A. Crawford wrote:
If the NIB instantiates everything how does the controller get a
reference to the View and the Model?
There are a couple of possibilities:
* The controller is in the nib. This is often the case with an
application controller in MainMenu.nib, for example. In that case,
you just connect the controller's outlets to the view(s). The
application controller often creates the model in code and so has a
reference to it that way. It's possible, although I don't
particularly recommend it, to instantiate your model object in the
nib, too.
* The controller serves as File's Owner for the nib. Again, you
connect outlets to views, but from File's Owner which at design time
is a stand-in for the object that will own the nib at run time. You
have to tell Interface Builder what the class of File's Owner will be
so it knows about your outlets. In this case, the controller may have
created the model or it might have been passed a reference to the
model when it was created (by another, superior controller).
Cheers,
Ken
_______________________________________________
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