Can't get NSTableView to use anything other than NSTextFieldCell

Discussion in 'Mac Programming' started by rossipoo, Dec 9, 2009.

  1. rossipoo macrumors regular

    Jun 7, 2009
    I want to use a subclassed NSTextFieldCell, which I got this working before in a different project, but now I can't figure out want could be wrong. For now I simplified it to just an NSImageCell, and that won't work either.

    - (id) tableView:(NSTableView *)aTableView
    objectValueForTableColumn:(NSTableColumn *)aTableColumn
    			 row:(NSInteger)rowIndex {
    	id cell = [[[NSImageCell alloc] init] autorelease];
    	[cell setImage: [NSImage imageNamed: @"Cool.pdf"]];
    	return cell;
    - (void) tableView:(NSTableView *)aTableView
    	forTableColumn:(NSTableColumn *)aTableColumn
    			   row:(NSInteger)rowIndex {
    	NSLog (@"%@", [aCell class]);
    The Log shows that aCell's class is an NSTextField, and the table view itself shows the description coming from the NSImage instance. I feel like I must be missing something obvious, but I don't know what.
  2. kainjow Moderator emeritus


    Jun 15, 2000
    Usually you set the cell in the nib by clicking through the scroll view > table > column > cell. Otherwise, set it via NSTableColumn (setDataCell:) in something like awakeFromNib.
  3. rossipoo thread starter macrumors regular

    Jun 7, 2009
    Hey, thanks champ.

    That's what it was exactly. I figured there must be some small detail I was missing. I looked up some NSTableView tutorials on the web, but I didn't find any that mentioned the fact.

Share This Page