Re: forwarding KVO from NSDocument to model
Re: forwarding KVO from NSDocument to model
- Subject: Re: forwarding KVO from NSDocument to model
- From: Cameron Hayne <email@hidden>
- Date: Wed, 11 May 2005 11:48:42 -0400
On 11-May-05, at 7:15 AM, Scott Anguish wrote:
if the NSDocument is KVC compliant for those keys, and you're
setting them using a KVC compliant means, the NSDocument should
work just the same as the existing model object.
On May 11, 2005, at 4:36 AM, Cameron Hayne wrote:
However, it is far from obvious how I should go about setting up
the "forwarding" of KVO so that the model changes will get
observed. I don't want to have to add an observer for each and
every model attribute - but I don't see a nice way to handle it
otherwise.
As I said in my original post, the NSDocument doe not have any
accessors or instance variables corresponding to the model's instance
variables - but it implements valueForUndefinedKey and
setValue:forUndefinedKey to forward *all* KVC requests to the model.
And this works well - changes in the view do cause changes in the model.
What I was asking about is the other direction - if the model
changes, how do I arrange that KVO makes the view change in response?
Note again that the model is not bound to the view objects - it is
the NSDocument (that has a reference to the model) that is bound to
the view objects. And I think there should be a *general* way to have
the KVO notifications take effect - without having to do it for each
individual model attribute separately.
I have not seen this situation mentioned in any documentation or
example. I find this surprising as I would have thought that it was a
common situation to have a document-based app where the model is not
in the NIB and hence it is necessary to do some "forwarding" of KVO.
--
Cameron Hayne
email@hidden
_______________________________________________
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