Re: IndexOfObject and bindings
Re: IndexOfObject and bindings
- Subject: Re: IndexOfObject and bindings
- From: Nicko van Someren <email@hidden>
- Date: Wed, 23 Mar 2005 12:10:53 +0000
On 23 Mar 2005, at 05:21, Julien Palmas wrote:
I want to bind one of the columns of my NSTableView with the index of
the objects inside the array. To get a column that would display no
more than 0, 1, 2, ....
I can't seem to find how to do it.
Is that something obvious or is that more complex ?
Bindings generally allow you to make use of attributes of the bound
objects. Since objects in an array don't by default know that they are
in the array (the array only references them, so they could perfectly
be in more than one array) the position of the object in the array is
not really an attribute of the object, so there is no way to get this
information directly from the arranged objects of an NSArrayController.
I can see several ways to do what you need. Probably the most general
way would be to sub-class NSArrayController to track the sorting of
objects and have a new key of arrangedObjectIndices: which would return
an array of NSNumbers identifying which object in the source array
landed in a given position in the arranged array. This requires a
moderate amount of work to implement. The quick and dirty solution
would of course be to add an index attribute to the objects in the
source array and then simply bind to that attribute in the table view.
Nicko
_______________________________________________
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