Re: Table view containing cells with both an image and text
Re: Table view containing cells with both an image and text
- Subject: Re: Table view containing cells with both an image and text
- From: Corbin Dunn <email@hidden>
- Date: Wed, 10 Dec 2008 13:38:35 -0800
Yeah, you are right, that is the case.
However, I'd recommend subclassing NSTextFieldCell and having it
draw an image. It'll make other stuff work for you automatically
(cell expansion tooltips, type selection). See: <http://developer.apple.com/samplecode/PhotoSearch/
>
Interesting.
So, it looks like what is going on here is:
willDisplayCell
is essentially be used to assign the additional information (such as
the image) the cell needs while objectValueForTableColumn returns
the primary text to be displayed.
Perhaps not quite a clean as I might have liked - would have
preferred to be able to simply return all of information needed by
the cell in objectValueForTableColumn rather then splitting it
between objectValueForTableColumn and willDisplayCell.
But, as you pointed out, the benefits gained by not writing all of
the extra code to support type selection, etc. makes it quite
worthwhile.
You could make the -objectValue something like an NSDictionary; the
drawback of this, is that it won't work as well with editing the
contents of the cell, so I don't recommend that approach. The above
approach is very common.
corbin
_______________________________________________
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