Advice on using NSCell
Advice on using NSCell
- Subject: Advice on using NSCell
- From: James Bucanek <email@hidden>
- Date: Thu, 2 Mar 2006 17:47:01 -0700
Greetings,
I'm attacking yet-another-table in Cocoa, and I've run into a reoccurring problem.
I have an NSTableView of data. The different columns store different types of data values (dates, sizes, other abtstact stuff). I've created formatters for all of the non-numeric and non-string values and NSCell handles all of the details beutifully.
Now I need to add some global behaviour to all of my cells. I need to change the appearance of the text in every cell of a row based on some criteria: Specifically, I want to draw the text in grey if the row represents an empty data record.
I can't find any clean, well organized, way of doing this. I assume I need to test a value in the data record then create an NSDictionary of text attributes for drawing. But where/how do I insert those attributes?
- If I change my table data source to return NSAttributedStrings instead of the raw data objects, I defeat all of the formatters I just wrote to handle the conversion of object values to text. I also lose all of NSCell's alignment features for numeric values.
- If I subclass NSCell and override setObjectValue to intercept the value and call setAttributedStringValue instead, I have the same problem.
- If I subclass NSCell and override drawInteriorWithFrame:, I lose most of the advantages of using NSCell in the first place. Plus, I'll probably break something down the line if the behaviour of NSCell ever changes.
I keep thinking that there must be some aspect of the NSTable/NSCell interface that I'm missing and that would allow me to add row-specific formatting to all cells without defeatings NSCell's formatter, alignment, and drawing routines.
--
James Bucanek
_______________________________________________
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