Re: Bindings: Custom Controller Keys ...
Re: Bindings: Custom Controller Keys ...
- Subject: Re: Bindings: Custom Controller Keys ...
- From: mmalcolm crawford <email@hidden>
- Date: Sun, 1 Aug 2004 13:14:31 -0700
On Aug 1, 2004, at 11:49 AM, J Nozzi wrote:
If you have 4 distinct collections of objects, then each should be
managed by a
different array controller. If all the collections are contained in
the same
collection in another object, then you will need a means of
separating them.
One means that comes to mind is to use indexed accessors -- create a
different
set of accessors for each subset...
So then, what's the best way to merge all the arrays' contents using
Bindings (so it's 'live) into one controller to view all these
different objects in one view? They all inherit from an abstract class
that holds all the common attributes that I want to display together.
I'm not sure now if I've understood your requirements.
Is the following example analogous to your situation?
You have an array of Products. Product is an abstract superclass of
LawnMower, Toaster, SurfBoard, and EggCup. You want to display a
composite view of all Products in one table view.
Is this is the case, simply bind the table columns as you would if you
had a homogeneous array to
[Product Array(*)].arrangedObjects.property
with Product Array's content array bound to:
[File's Owner(*)].productsArray
(*) or whatever.
You won't be able to "sensibly" connect a button to the array
controller's addObject: action since you'll probably define the "Object
Class Name" to be Product, but you could subclass NSArrayController to
provide addLawnMower:, addToaster: etc. methods...
If you need to display toasters, egg cups, and surf boards in different
table views, then they should be managed by different array controllers
-- even if they're contained in the same array. One way to do this
might be to provide indexed array accessors for the different "virtual"
arrays, that all refer back to the "composite" array:
- (int)countOfLawnMowers
{
// return number of lawn mowers in productsArray
}
mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.