Friday, March 28, 2003

iAppViews

Nicholas Riley links to iAppViews, code by Evan Jones that apparently demonstrates best practices for alternating background colors in NSTableView and NSOutlineView.

2 Comments RSS · Twitter

Even when subclassing, it is *very* difficult to duplicate the behaviour of Apple's iApps exactly. I've struggled with this problem a lot, since I have an app that prominently features an alternating-color table view.

I would sum up the crux of the problem this way: when you call "display:" on NSTableView, it only redraws the part of the table that actually contains data. This means that you have to resort to a lot of weirdness to get alternating lines to appear down the whole table when there aren't enough data rows to fill the area (as they do in, say, iTunes). This also creates a big problem if you want vertical grid lines (again, like in iTunes) to be drawn all the way from the top to the bottom of the NSTableView, rather than simply down to the point where the data ends.

This is the first time I've seen the classes you're linking to above, but it looks like (from the screenshots) that the author has chosen to just accept that NSTableView only wants to redraw the rows that contain data. He also doesn't include support for vertical gridlines. This is definitely a valid approach, but my goal has always been to match the iApps as closely as possible.

For my money, Tony Arnold has the best implementation of the "iTunes-style" table view out there. You can check it out here:

http://members.iinet.net.au/~tonyarnold/archives/000004.html

Tony's implementation addresses the issues I talked about above, and his has the added benefit of being able to base the row colors on current system preferences. The table view I use in PodWorks is actually a stripped down version of Tony's.

Thanks for the link, Buzz!

Leave a Comment