Re: NSTableView, NSArrayController, and ImageAndTextCell
Re: NSTableView, NSArrayController, and ImageAndTextCell
- Subject: Re: NSTableView, NSArrayController, and ImageAndTextCell
- From: Alastair Houghton <email@hidden>
- Date: Sat, 8 Nov 2003 09:37:20 +0000
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.