Re: Custom Cell not working in NSTableView
Re: Custom Cell not working in NSTableView
- Subject: Re: Custom Cell not working in NSTableView
- From: Matt Neuburg <email@hidden>
- Date: Thu, 17 Aug 2006 09:40:58 -0700
- Thread-topic: Custom Cell not working in NSTableView
On Thu, 17 Aug 2006 07:58:20 -0500, Todd Freese
<email@hidden> said:
>Thanks! I was looking so hard for something complex, that I missed
>the incredible simple syntax error. I works like a charm now.
Right, but I think the take-home lesson is a mental revision of what
"looking" means. I didn't spot it either, obviously; that's why I asked for
enough code to allow me to reproduce your project. As soon as I did
reproduce it, though, I ran it in the debugger and the cause of the problem
became instantly dead obvious. Always, always, use NSLog() and/or the
debugger - preferably before posting! :) m.
>On Aug 16, 2006, at 9:20 PM, Matt Neuburg wrote:
>
>> On or about 8/15/06 7:56 PM, thus spake "cocoa-dev-
>> email@hidden"
>> <email@hidden>:
>>
>>> Message: 7
>>> Date: Tue, 15 Aug 2006 20:36:04 -0500
>>> From: Todd Freese <email@hidden>
>>> Subject: Custom Cell not working in NSTableView
>>> To: Apple Cocoa List <email@hidden>
>>> Message-ID: <email@hidden>
>>> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>>>
>>> I have a custom cell that displays an icon and text. It is a lift
>>> from the DragNDropOutlineView sample code. The data comes from a Core
>>> Data Entity and uses an NSArrayController and bindings to put the
>>> text into the custom cell. The problem is that all the rows contain
>>> the same icon, but the text is correct.
>>>
>>> Since you can only bind one value, I have the following code to set
>>> the icon image.
>>>
>>> - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell
>>> forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
>>> {
>>> switch (rowIndex) {
>>> case 0:
>>> [aCell setImage:[NSImage imageNamed:@"icon1"]];
>>> default:
>>> [aCell setImage:[NSImage imageNamed:@"FolderRef"]];
>>> }
>>> }
>>
>> The problem is that the default: statement is always being
>> executed, so
>> every cell gets the folderref image. Put a "break;" statement
>> before the
>> default: label and all will be well. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden