Re: Rendering an Array Controller contents outside an NSTableView
Re: Rendering an Array Controller contents outside an NSTableView
- Subject: Re: Rendering an Array Controller contents outside an NSTableView
- From: Chris Hanson <email@hidden>
- Date: Tue, 3 Apr 2007 15:30:42 -0700
On Apr 3, 2007, at 12:12 PM, Kevin Hoffman wrote:
I'm a complete Cocoa newbie, so if there is already a control for
doing this, please let me know. Basically I am looking for a strategy
that I can use in order to render some items out of an array
controller
(fed by Core Data) onto a surface that isn't a standard table like
NSTableView. Basically I have an entity called Thumbtack (title, xloc,
yloc). The array controller is bound to the thumbtacks. What I want is
to make it so that I can bind (something???) to the array controller
such that it will put thumbtacks in the appropriate x/y positions, and
when I add an item to the array controller, a new thumbtack appears,
etc.
Rather than thinking of it as "rendering" an array controller, just
consider the array controller a data source for your view. It just
provides access to some content via a standard API -- whether you bind
to it, or whether you invoke its methods.
As Todd Ransom has pointed out, there are examples of creating custom
views that you can bind to a controller (including an array
controller) on Malcolm's page:
http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
The example you're looking for is Graphics Bindings.
One hint on implementing bindings for your own view: Create a helper
object to represent each of your view's bindings, and have it do the
heavy lifting of observing the value at the bound key path and
modifying your view's internal state when it changes, and pushing your
view's state to the bound key path when necessary as well. If you
have a view that requires several bindings, this will make managing
them a bit easier and keep the bindings management more independent
from your view's main flow of control.
-- 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