• 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: Saving NSObjectController info
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving NSObjectController info


  • Subject: Re: Saving NSObjectController info
  • From: mmalcolm crawford <email@hidden>
  • Date: Tue, 15 Feb 2005 10:18:16 -0800


On Feb 15, 2005, at 1:28 AM, <email@hidden> wrote:

I have a very basic doc-based application. I want to implement an NSObjectController to manage the model object it contains. Nothing fancy here, just a single object and nothing more.

I know how to set this all up. I've done the examples (CurrencyConverter with Bindings and all of that), that's not the issue. What I want to be able to do is give the user the ability to save the object information to disk in the form of an archived file. Now, my model object is already set up for this (NSCoding, yadda yadda), as well as MyDocument being able to save and retrieve the info from disk.

But where do I get the info from? Through the user interface, the values in each text field are stored in the model object instance that NSObjectController creates, but how do I programmatically get at that object instance so I can archive it and save it do disk, and subsequently unarchive it to open a file?

Then: On Feb 15, 2005, at 3:24 AM, <email@hidden> wrote:

Nevermind, actually figured this out on my own. For those that might be wondering (I'm sure you're out there somewhere), what I did was make an outlet in MyDocument of type NSObjectController, connected the NSObjectController in IB to the outlet, then just used content: and setContent: methods in place of the earlier methods I was using with a custom controller object.


For what you describe, you should not need to make an outlet to the object controller. It is the responsibility of the document instance to manage the model (including archiving and unarchiving). The 'content' of the object controller should be bound to the relevant attribute of the document. As changes are made in the user interface, they are automatically propagated to the model (using KVC)... backing up to the bindings Big Picture -- recall that the goal is to keep user interface and model values in sync.


mmalc


_______________________________________________ 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: Saving NSObjectController info
      • From: James McConnell <email@hidden>
References: 
 >Saving NSObjectController info (From: <email@hidden>)

  • Prev by Date: Re: UDP SOCKETS!!
  • Next by Date: Re: Beta testers needed
  • Previous by thread: Saving NSObjectController info
  • Next by thread: Re: Saving NSObjectController info
  • Index(es):
    • Date
    • Thread