Re: NSTableView, NSArrayController, and ImageAndTextCell
Re: NSTableView, NSArrayController, and ImageAndTextCell
- Subject: Re: NSTableView, NSArrayController, and ImageAndTextCell
- From: Vincent Coetzee <email@hidden>
- Date: Sat, 8 Nov 2003 11:59:39 +0200
Hi Alistair
I would suspect that using a subclass of NSCell, and asking that to
retrieve it's own object value and then drawing appropriately would
work in a much cleaner fashion, HOWEVER, my understanding of
setObjectValue: is that it is used to store some sort of semantic
object that the cell represents rather than the actual parameters
required by the cell itself, and hence I would think that the
implementation using it's own object value may well cause re-use
problems somewhere down the line.
Vince
On Nov 08, 2003, at 11:37, Alastair Houghton wrote:
On 8 Nov 2003, at 07:47, mmalcolm crawford wrote:
Notice from the outline view example that the image is set
independently of the text:
- (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell
*)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item {
if ([[tableColumn identifier] isEqualToString: COLUMNID_NAME]) {
// Make sure the image and text cell has an image. If not, give it
something random.
if (item && ![NODE_DATA(item) iconRep]) [NODE_DATA(item) setIconRep:
[self _randomIconImage]];
// Set the image here since the value returned from
outlineView:objectValueForTableColumn:... didn't specify the image
part...
[(ImageAndTextCell*)cell setImage: [NODE_DATA(item) iconRep]];
// ...
It's cleaner IMHO to write the cell's -setObjectValue to accept an
object that contains both text and an image (you could use an NSArray
with two elements, or you could use a custom container object of some
type). That way you don't have to set the image or the text in your
willDisplayCell: method... you just do it the usual way, by returning
your object from objectValueForTableColumn: method.
I see no reason why that wouldn't work with NSArrayController.
Kind regards,
Alastair.
_______________________________________________
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.
_______________________________________________
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.