There is a good example here: http://www.cocoadev.com/index.pl?IconAndTextInTableCell You create your own NSCell that draws an image and text
@interface IconCell : NSCell { NSArray * cellValue; } - (void)setObjectValue:(id <NSCopying>)object; - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; @implementation IconCell - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { NSDictionary * textAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont userFontOfSize:10.0],NSFontAttributeName, nil]; NSPoint cellPoint = cellFrame.origin; [controlView lockFocus]; [[cellValue objectAtIndex:1] compositeToPoint:NSMakePoint(cellPoint.x+2, cellPoint.y+14) operation:NSCompositeSourceOver]; [[cellValue objectAtIndex:0] drawAtPoint:NSMakePoint(cellPoint.x+18, cellPoint.y) withAttributes:textAttributes]; [controlView unlockFocus]; } - (void)setObjectValue:(id <NSCopying>)object { cellValue = (NSArray *)object; } @end
source share