Re: Line Numbers in Tables
Re: Line Numbers in Tables
- Subject: Re: Line Numbers in Tables
- From: Gordon Apple <email@hidden>
- Date: Wed, 29 Aug 2007 15:07:17 -0500
I haven't used data sources yet and decided to plunge headlong into
Bindings, which after a steep learning curve and a lot of experimentation
has proved viable. My data structure has virtually no code and I have only
had to subclass NSArrayController and NSTreeController to override the "add"
function, and that was to support my popup that says where to insert. Of
course, with NSTreeController, the later required a lot of futzing around
with paths plus a hard-coded switch statement of object types per path
length.
I was hoping to do this without messing with the views. The controllers
obviously have internal access to everything I need, but I haven't found a
way to get at it and make them do what I want.
Although line numbers would be good in outline view, they would be
harder to do. I would be happy to just get them in my table views (one for
each level in the hierarchy). I could maybe get indices from
"arrangedObjects" and increment by one. The problem is that I haven't been
able to figure out a keyPath and function that will allow a binding to
enumerate the rows of the bound column. IMHO, this is something that should
be built into the controllers. I'm sure I'm not the only one who would like
line numbers.
> On Wed, August 29, 2007 12:07 pm, Gordon Apple said:
>> Simple function -- apparently no simple solution. I just want to put
>> line numbers in one column of a table. I want them to start at "1" and
>> stop at the last table entry. Nothing I've tried works and I've searched
>> available resources.
>
> Have you tried returning the row number in the
> tableView:objectValueForTableColumn:row: datasource method? I'd think
> that should work...
>
> Something along the lines of:
>
> tableView:table objectValueForTableColumn:column row:row {
> if ([column identifier] == <number_column>) {// Obviously this is wrong.
> return [NSNumber numberWithInt:row];
> }
> }
>
> (You many want row+1, of course.)
>
> This of course means you are using a datasource and not bindings/KVC, but
> the difference isn't all that great...
>
> Daniel T. Staal
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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