• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Question about Saving a document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about Saving a document


  • Subject: Re: Question about Saving a document
  • From: Francis Derive <email@hidden>
  • Date: Thu, 15 Jun 2006 12:15:08 +0200


On Jun 14, 2006, at 10:45 PM, Paul Lynch wrote:
On 14 Jun 2006, at 11:48, Francis Derive wrote:

Paul,

You say "You don't want to have your model instantiated in the nib" but, in the Apple's "Developing Cocoa Applications Using Bindings: A Tutorial", this is what is made : an instance of the model named "Converter" is instanciated in the nib, then an instance of an NSObjectController - the content of which is the above model, etc...

You shouldn't assume that Apple examples all follow best practices (they try, but can't always succeed), nor that their examples are always entirely typical usages.


Paul,
I had envisage this argument - an example always being a toy-example - but I can't be convinced about what would seem a deficiency as I will show.



What could I do from a nib if there were nothing in it ?

This question indicates that you haven't understood the example very well.

That's so much true, and many thanks for taking care.

A nib will certainly contain many view objects (windows, buttons, fields, etc), as well as instantiated controllers, both bindings controllers and your own classes.
Your controller objects will interact with both view objects, and model objects. Most commonly, model objects are instantiated inside your controllers. In a few cases, and the CurrencyConverter is one, you can have a model object that is instantiated inside the nib, simply because it is convenient to do so.

"simply because it is convenient to do so" - but isn't it why nibs can be so useful, I mean even in *real scale examples* ?
If you are right, I immediately rework ( I had done it, and I do it again here ) this currency converter example by
- deleting the Converter NSObject instance ( the Model ) from the nib, and
- I create an NSDocument subclass with, as you said, an instance variable set to the model object ( I will have to show you how I do that, because I had doubts about my doing that ).


But this point : do I keep in the nib the Object Controller ( the content of which had been set to the above model object in IB ), or do I delete it also ?
If I were to keep it in the nib, I would have to do the connection between this Object Controller and its model object - which is now an instance variable of the above NSDocument subclass. Programmatically, by a setContent method - if I am not wrong ?
Again, it will be hard to believe that IB was useful only for this toy example !


You need to implement a connection from your document controller to the converter object,

"document controller" ? Isn't going too far ?
and refer to it in the load and save methods. See previous posts. However, there isn't any reasonable way to implement load functionality unless you move the converter object inside your controller, as you can't just replace the nib instantiated object. Again, see previous posts.

You aren't going to be able to simply "extend" this example; sometimes, you have to make changes to previous approaches into order to move forwards.

I am ready to make changes to what is a toy-example - and I want to learn how to do that -, but if extending the case for what is only but a little step forward ( saving/reading to/from a file ) is too much so that the toy-example succumbs to show evidence of anything worth, where are we going to with Cocoa bindings.
I am still convinced there is a way to do it.


Perhaps some of the Apple documentation people on this list will take your suggestion and update the tutorial for you.

Paul

Many thanks to you.

Francis.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Question about Saving a document
      • From: Paul Lynch <email@hidden>
References: 
 >Question about Saving a document (From: Francis Derive <email@hidden>)
 >Re: Question about Saving a document (From: Paul Lynch <email@hidden>)
 >Re: Question about Saving a document (From: Francis Derive <email@hidden>)
 >Re: Question about Saving a document (From: Paul Lynch <email@hidden>)

  • Prev by Date: Setting the background color of an NSBrowser column
  • Next by Date: Re: real noob question about CF functions with Cocoa
  • Previous by thread: Re: Question about Saving a document
  • Next by thread: Re: Question about Saving a document
  • Index(es):
    • Date
    • Thread