Re: display NSXMLDocument with NSOutlineView and NSTreeController
Re: display NSXMLDocument with NSOutlineView and NSTreeController
- Subject: Re: display NSXMLDocument with NSOutlineView and NSTreeController
- From: Chris Hanson <email@hidden>
- Date: Mon, 16 Apr 2007 13:42:55 -0700
On Apr 16, 2007, at 10:55 AM, Torsten Curdt wrote:
Unfortunately that example does not show this for a NSOutlineView
(and I don't see how to make it use one ;-) ).
On a button click I open a panel, select a file, parse that file
into a NSXMLDocument and would like to feed that into a NSOutlineView.
Now sure what I am after?
The central issue is that you see this as a case of "feeding" data
"into" an NSOutlineView. What you actually do is provide data to an
NSOutlineView. You can do this in one of two ways:
(1) Create a data source for the outline view that follows the
NSOutlineViewDataSource informal protocol, and provides information
from your XML document.
(2) Use an NSTreeController that is appropriately bound to your model
objects to provide data to the outline view; populate your model
objects with information from your XML document.
Everything in Cocoa follows a Model-View-Controller architecture,
where a controller object (which isn't necessarily a subclass of
NSObjectController or NSWindowController) mediates between model
objects containing your data and view objects that display and let the
user interact with a representation of it.
In other words, you never push your data into views; the most you do
is — in controller-level code only — push a representation of your
data into views. For display, you should almost always be interacting
with your model objects on a "pull" basis. If you remember this
design pattern, the way to accomplish whatever you try to do in Cocoa
should become much clearer.
-- 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