• 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
custom formatters and preparedCellAtColumn:row:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

custom formatters and preparedCellAtColumn:row:


  • Subject: custom formatters and preparedCellAtColumn:row:
  • From: Kurt Bigler <email@hidden>
  • Date: Tue, 18 May 2010 19:02:04 -0700
  • Thread-topic: custom formatters and preparedCellAtColumn:row:

I'm using a custom object type in an NSOutlineView, for which a displayable
text value is obtained from my custom formatter's stringForObjectValue:
method.

To get easy control over text and background colors and alignment for
individual row/columns, I override preparedCellAtColumn:row:.

I'd like a reality check on the following.

My plan is to call stringForObjectValue: from preparedCellAtColumn:row:, and
store the resulting NSString (via setObjectValue:) into the cell that
preparedCell... provides.  It turns out I need the text, to determine the
colorization in some cases.  I figure calling setObjectValue: to replace the
custom class object value with its textual representation would prevent the
cell drawing code from calling stringForObjectValue: *again* to convert the
custom value to text.  It would seem to be a "throw away" situation anyway,
with the cell being reused for the whole column so nothing is lost by
replacing this value at display time.  Right?

I tried it, my app still works, and it appears setObjectValue: is not
getting called except from the preparedCell... override.


Questions are:

* Is it "a good idea" for preparedCell... to replace the custom object value
with the text value like this?

* Does it in any way encumber the reuse of the cell for the entire column?

* Should I be making a copy of the cell passed to preparedCell... and
modifying and returning the copy instead of modifying the provided cell?

* Should I instead be maintaining separate cells per ROWxCOLUMN or perhaps
separate pre-prepared cells for each combinations of text display
attributes?  (There are a finite number of attribute combinations.)


This is all guesswork for me.  I don't find that the doc really helps me
understand this in-depth and I have crafted a lot by trial and error.

Mostly I'd like to avoid creating unnecessary performance hits, since this
outline view gets updated at a high rate by incoming realtime data.


All thoughts are welcome.  Thanks in advance.

-Kurt Bigler


_______________________________________________

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

  • Prev by Date: Re: NSTask and piped commands
  • Next by Date: Re: Programmatic Binding
  • Previous by thread: Re: Get controller from nib
  • Next by thread: Custom View Binding, Arrays, and observeValueForKeyPath
  • Index(es):
    • Date
    • Thread