Re: NSTableView -setDataCell confusion
Re: NSTableView -setDataCell confusion
- Subject: Re: NSTableView -setDataCell confusion
- From: Raleigh Ledet <email@hidden>
- Date: Mon, 29 Jun 2009 16:09:29 -0700
On Jun 28, 2009, at 10:05 PM, Quincey Morris wrote:
On Jun 27, 2009, at 13:18, Chase Meadors wrote:
I'm using AMIndeterminateProgressIndicatorCell (at least the
drawing code) to imitate a progress indicator in the table view. To
get it to use the custom cell, I've been calling
[myTableColumn setDataCell:[[MyCustomClass alloc] init]];
However, I've run into a 'slight' problem. Apparently, ALL of the
cells in this column are that one, same, object. When I tested with
F-script, I found that they have the exact same description, and
same memory address. This explains why bindings affecting one cell
would affect all of them...
So, in short, is there a +setCellClass method or similar for
NSTableColumn? Any way to make it use different objects?
You can use the table view delegate method:
tableView:dataCellForTableColumn:row:
to implement different cells for different rows.
Yes, but that won't really solve his problem. NSTableView likes to use
the exact same cell over and over again to draw row/column contents
very quickly. While Chase can use
tableView:dataCellForTableColumn:row:, NSTableView won't retain that
cell. Chase would need to retain the cell in the delegate. However,
even doing that, you won't get the animation that Chase is looking for.
So your choices kinda come down to the following:
a) Give up on the animation. Then you can use the same cell for the
entire column. Each row will return the correct value that the
progress indicator should draw. Be sure to invalidate the row/column
as the value changes to redraw the cell with the new value.
b) Place actual NSProgressIndicator views into the table view. This is
somewhat tricky to do and maintain an acceptable level of performance.
The basic outline is that you should create your own NSTableView
subclass, override viewWillDraw: and add / remove views such that you
only have indicator subviews for the visible rows. With actual views
in place, the animation will be done properly.
-raleigh
_______________________________________________
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