view-based nstableview advice

35 views
Skip to first unread message

Rick C.

unread,
Apr 2, 2012, 2:58:35 AM4/2/12
to Cocoa-Dev List
Hi,

Just trying to make sure I'm on the right track here...so I'm doing my first view-based table view and I do like how I can set a lot of things up in IB like text fields, etc. But I want to customize the rows (give them a gradient, etc.) so am I understanding correctly that I should drag out a custom view in IB onto my table view and set that to a subclass of NSTableRowView, set its identifier to NSTableViewRowViewKey, then do my custom drawing in that subclass? I'm asking because it seems I can do custom drawing in a NSTableCellView subclass as well? Thanks for the pointers,

rc
_______________________________________________

Cocoa-dev mailing list (Coco...@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev-garchive-98506%40googlegroups.com

This email sent to cocoa-dev-ga...@googlegroups.com

Uli Kusterer

unread,
Apr 2, 2012, 3:24:47 PM4/2/12
to Rick C., Cocoa-Dev List
On 02.04.2012, at 08:58, Rick C. wrote:
> Just trying to make sure I'm on the right track here...so I'm doing my first view-based table view and I do like how I can set a lot of things up in IB like text fields, etc. But I want to customize the rows (give them a gradient, etc.) so am I understanding correctly that I should drag out a custom view in IB onto my table view and set that to a subclass of NSTableRowView, set its identifier to NSTableViewRowViewKey, then do my custom drawing in that subclass? I'm asking because it seems I can do custom drawing in a NSTableCellView subclass as well? Thanks for the pointers,


If I understand you correctly, you're mixing things up. The identifier is the reuse identifier. I.e. all cells with the same identifier are considered interchangeable when the table needs a new cell, so if there's an unused cell with the same identifier, it will be used.

Setting the identifier has no effect on the kind of cell class that is created. The cell class is determined by the "Custom Class" of the view in the XIB file, not by its identifier.

You could theoretically use the same class for all your cells, but use different constructors to set up their internals differently based on different reuse identifiers. That's why the identifier is separate from the cell class.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.lookandfeelcast.com

Rick C.

unread,
Apr 2, 2012, 8:10:42 PM4/2/12
to Uli Kusterer, Cocoa-Dev List
It's definitely possible I'm mixing things up. :-)

So to create a subclass to further customize the look of my cells beyond the basics I should be subclassing NSTableRowView correct? From what I've seen in the documentation Apple is just dragging a new view onto the table view and setting that view to their subclass right? Since there's no actual NSTableRowView object in IB. But if I don't set its User Interface Item Identifier to NSTableViewRowViewKey the table view will not draw with my subclass. Ok I suppose I could write it in code but I was trying to do it as code-free as possible. Thanks for the help,

rc

Reply all
Reply to author
Forward
0 new messages