Re: index column in bound NSTableView
Re: index column in bound NSTableView
- Subject: Re: index column in bound NSTableView
- From: Alex Rosenberg <email@hidden>
- Date: Tue, 25 Jan 2005 10:04:57 -0800
On Jan 24, 2005, at 1:43 PM, Matt Neuburg wrote:
On Mon, 24 Jan 2005 08:30:42 -0800, Alex Rosenberg <email@hidden>
said:
On Jan 23, 2005, at 10:50 AM, Matt Neuburg wrote:
On Fri, 21 Jan 2005 14:37:09 -0800, Alex Rosenberg <email@hidden>
said:
Given an NSTableView using bindings, is there a simple way to add a
column of the original array index numbers?
The numbers should properly jumble when the the table is sorted.
The array is presumably an array of something - like, mutable
dictionaries.
So I would write a routine that runs through the array, and adds to
each
mutable dictionary a key-value pair whose key corresponds to the
extra
column in the table and whose value is the index number. m.
Unfortunately, it's never that simple. One would need to track all
rearrangements and walk through the entire thing and shift or reindex
it as objects are inserted/deleted/rearranged.
You said "a column of the *original* array index numbers". I don't get
how
that squares with "track all rearrangements". It's possible I didn't
understand the question. It wouldn't be the first time. Feel free to
restate
it. Also, feel free to look at the source code of my Thucydides app
(the
source code that uses bindings) for an example of how to present in the
interface a different bound array than the one that is lurking in the
background ready to be restored at any time; this might be relevant,
though
I can't tell because, as I say, I no longer have any sense of what
you're
asking. m.
As one manipulates the NSTableView UI, the NSArrayController changes
both your data array and the one it uses to display the data. For
example, if you click a column header to sort the TableView, it does
not sort your data, but rater a mutableCopy of your array. If you call
add: or insert: in the NSArrayController, it mutates both your data
array and it's own copy.
I looked at your app. It's quite similar to my own in that I also have
a shadow array simply because my original data is a set of C++ legacy
objects. I was trying to avoid mentioning that complication here.
An example of what I want to achieve can be seen in Mail.app's Viewer
window if you enable the Number column. This number is a property of
the array, not of the elements inside the array, so ideally it is not
provided by a message to each element.
+------------------------------------------------------------+
| Alexander M. Rosenberg <mailto:email@hidden> |
| Nobody cares what I say. Remove the underscore to mail me. |
_______________________________________________
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