Re: File's Owner
Re: File's Owner
- Subject: Re: File's Owner
- From: Ken Thomases <email@hidden>
- Date: Sun, 25 May 2008 04:44:36 -0500
On May 25, 2008, at 4:14 AM, mmalc crawford wrote:
On May 25, 2008, at 2:01 AM, Roland King wrote:
Where do I make the model object and how do I hook it into the
controller? I start the application, the Files Owner is the
singleton NSApplication, I guess I can override the NIB finished
loading method, make the model object there and now I want to call
something on the controller like ...
-(Controller)hereIsYourModelObject:(Model*)model
If you override -awakeFromNib then you'd do so in the controller
class, so it would create and set its own model. There's no need to
invoke a separate hereIsYourModelObject: method, except in the sense
of a setModelObject: accessor.
Alternatively you could do it in -init...
This is akin to, in the document architecture, the document object
setting its model by retrieving it from a file.
Another approach is to not put the controller in the nib. Have the
controller be the File's Owner. So, the controller is created in code
in response to some action or notification or delegate method (e.g.
applicationWillFinishLaunching:). Then the nib is loaded, and the
controller is passed in as its owner. In the nib, everywhere that you
had a connection to or from the controller, you make that connection
to or from the File's Owner.
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