Re: Problems with NSCell setObjectValue
Re: Problems with NSCell setObjectValue
- Subject: Re: Problems with NSCell setObjectValue
- From: Quincey Morris <email@hidden>
- Date: Sun, 8 Aug 2010 22:14:20 -0700
On Aug 7, 2010, at 10:16, Hrishikesh Murukkathampoondi wrote:
> I subclassed NSCell to return a custom cell value for a NSTableView. Within the function
>
> - (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
>
> I set the objectValue for the MyCell object (subclass of NSCell) using setObjectValue (I am passing it a NSString). After I set this I printed out the value [mycell objectValue] and also checked if this works [mycell hasValidObjectValue].
>
> The value is printed correctly.
>
> When MyCell's - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView method is called I print the objectValue and it is nil!!
>
> When I try the same thing using setRepresentedObject it works fine.
>
> What am I doing wrong when I use objectValue?
The 'dataCellForTableColumn:...' delegate method is intended to return a data cell for the table column to use, but *not* to configure the cell value for the specific row it's going to represent. Remember that the object value comes from the data source object, not the delegate object, and it's therefore wrong for the delegate object to try to supply the value.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden