Re: Saving NSObjectController info
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