Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using NSCell to bold cells in a tableview



On Sat, 28 Dec 2002 11:10:46 -0800, Mike Ferris <email@hidden> said:

> - You could subclass NSTableColumn and return different cells for
>-dataCellForRow:
> - You could implement
>-tableView:willDisplayCell:forTableColumn:row: in your table view
>delegate and set the one data cell's font appropriately each time it is
>used.
> - You could return attributed strings from your dataSource's
>-tableView:objectValueForTableColumn:row: instead of a simple string
>and have the attributed strings be bold or not (or whatever)
>
>Which one is right for you depends. Since the cells are always textual
>in your case and it is just the font changing, I would steer clear of
>the first possibility. -dataCellForRow: is most useful for cases like
>PropertyListEditor where different classes of cell

That's a good point. I originally developed my way of handling dataCellForRow: in a situation where some cells were buttons and some were text, so naturally whenever the matter comes up now I simply reduce it to the previously solved problem... :)

Incidentally, the way I do this is to have a subclass of NSTableColumn whose dataCellForRow: turns to the datasource for the actual cell. This way, my NSTableColumn subclass is universally useful, since it doesn't contain any actual functionality (that is, it knows nothing about how to generate the cells or even whether there is a need to do so); if the datasource implements the corresponding method (which I call dataCellForRow:sender:), it is called, otherwise the default behaviour is used. Thus, in my project, *every* table column is a MyTableColumn. In my view this is how dataCellForRow: should have been implemented in the first place, thus making subclassing unnecessary. m.

matt neuburg, phd = email@hidden, http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.