Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Littleodie914

macrumors 68000
Original poster
Jun 9, 2004
1,813
8
Rochester, NY
Hey guys, I'm trying to draw an NSImage in a NSCell using an NSTableView delegate method.

Here's what I'm trying:

Code:
- (void)tableView:(NSTableView *)tableView 
  willDisplayCell:(id)cell
   forTableColumn:(NSTableColumn *)column 
			  row:(int)row
{
	NSSize mySize;
	mySize.width = 32;
	mySize.height = 32;
	NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:[[[filesController arrangedObjects] objectAtIndex:row] valueForKey:@"filePath"]];
	[icon setSize:mySize];
	
	[cell initImageCell:icon];
	[cell updateCell:cell];
	[tableView reloadData];
	
}

I also am using the (float)tableView:(NSTableView *)tableView heightOfRow:(int)row method, which works fine, but I can't figure out why the image won't draw. It places an object in the table, and it responds to double-clicks as my text objects do, but nothing is actually drawn, it's just a blank selectable space. Any pointers? Thanks! :D
 

Littleodie914

macrumors 68000
Original poster
Jun 9, 2004
1,813
8
Rochester, NY
And as an added bonus, I seem to have "lost" my menu. :(

The main menu bar, where you change things from NewApplication to <name of application>, seems to have gone missing. It doesn't show up in IB, and there's no instance of it in the Instances window. (I don't remember if there should be or not, but mine has disappeared either way!) Anyone know how to get it back? :eek:


Edit: Scratch that, forgot that in a Document-based app, the MainMenu is changed in MainMenu.nib, while GUI work happens in MyDocument.nib :eek:
 

Littleodie914

macrumors 68000
Original poster
Jun 9, 2004
1,813
8
Rochester, NY
Look for Apples ImageAndTextCell.h class in your examples folder or online. It is a great subclass to start from.
Thanks a lot for the idea, I'll check it out. Seems like there would be an easier way though, than having to subclass the entire thing and add a bunch of methods. :confused:

Edit: Got it working, and once the tedious linking and what-not is out of the way, it's actually not too bad :) Thanks a lot for the link!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.