Re: Model changes behind NSTreeController's back
Re: Model changes behind NSTreeController's back
- Subject: Re: Model changes behind NSTreeController's back
- From: Chris Hanson <email@hidden>
- Date: Thu, 15 Feb 2007 17:43:36 -0800
On Feb 15, 2007, at 3:17 PM, Mark Alldritt wrote:
I know that I should go through NSTreeController's APIs to alter the
underlying model, but my application allows the user to view the
same model
in several forms.
You should go through model object APIs to manipulate model objects,
not through the APIs of controller or view objects. The
NSTreeController APIs should be used by view/controller-layer code,
not model-layer code.
This means that I have an NSOutLineView driven by
NSTreeController and I have a custom view displaying and editing the
same
model graphically. Its also possible the model may appear through
this
arrangement of views in multiple windows.
This is why I suggest the above. Controller objects manage
interaction between view and model objects; the decoupling is there
explicitly to make it easy to create interfaces like the above.
My custom view posts KVO notifications when it changes the model, but
NSTreeController is failing to notice and as a result, the
NSOutlineView
falls out of sync.
Does anyone have any suggestions on how to get NSTreeController to
update
its NSOutlineView under this kind of situation?
One object should not be posting KVO notifications "on behalf of"
another. Your model objects, when changed, should post their own KVO
notifications. Your controllers and the views they're managing are
what should be observing these notifications and reacting to them.
-- Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden