• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Advice on using NSCell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Advice on using NSCell
      • From: Keith Wilson <email@hidden>
  • Prev by Date: Re: NSXMLDocument question
  • Next by Date: Re: Transparent window
  • Previous by thread: Re: Replicating the system wide contextual menu
  • Next by thread: Re: Advice on using NSCell
  • Index(es):
    • Date
    • Thread