On 25 May 2008, at 08:15, Johnny Lundy wrote:

Well, tell that to the guy who wrote the Currency Converter Using Bindings tutorial. See the last sentence here:

[...]

And you wonder why I am still confused. That paragraph from Apple directly contradicts what you just said.

The Converter object is continually referred to as the Model Object. That is exactly how mine are set up - connected to the Controller Object. The tutorial says nothing about File's Owner.

That's a rather unfortunate example for you because it's a tutorial directly targeted at learning the basics of bindings. It's more convenient for the tutorial to instantiate a model object in the NIB, but you wouldn't normally do that in a larger application. It would make it a pain to access the model from other NIBs for example.

Normally your model objects would be created in code that didn't care about NIBs or any UI objects. Then you would have a few NIBs that deal with different aspects of your application and they have to access the shared model objects (shared amongst all NIBs). How would the controllers in these NIBs access the model? Via one of the proxy objects. Which one (Application or File's Owner) depends on whether the model is a global resource or something specific like a document. It also depends on the NIB and what it expects its owner to be.

If you look through the apple samples instead, you can find examples of different ways of instantiating NIBs and different ways of binding to model objects (that hopefully aren't in the NIBs).

Examples:

  A simple application with one model and a MainMenu.nib
As the NIB is loaded by the AppKit automagically, File's Owner is just the application object - same as the Application proxy

 A document-based application with a MyDocument.nib
The NIB is loaded by the AppKit and File's Owner is the window controller.
     Access to the document and its model is via the File's Owner.
     Access to global data is via the Application proxy.

 A custom application with NIBs for custom views.
The NIB is loaded from custom code and File's Owner is whatever you set it to - probably a subclass of NSViewController. Access to model objects specific to that instance of the view would be through the File's Owner.
    Global data via the Application Proxy.


One last thing: Setting the class of File's Owner in interface builder is only so that IB can see what outlets and actions it has. It doesn't change what is actually there because the real object is created before the NIB is loaded.

pt.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to