> On Apr 7, 2017, at 4:43 PM, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> On Apr 7, 2017, at 07:24 , Daryle Walker <dary...@mac.com 
> <mailto:dary...@mac.com>> wrote:
>> 
>> Does anyone have any ideas how to do this a runtime? I need to intercept 
>> when a table cell is created so I can either change its font property or set 
>> a font binding.
> 
> Do you implement tableView:viewFor:row: in your delegate? That’s the (well, 
> a) place to configure table cells.

This is what I did, although I was initially nervous because I didn’t want to 
handle cell-view creation. There is another delegate method that notifies you 
of when a view is about to be used for a cell; I overrode that first, but it 
never got called (or at least the “guard” checking if the view was a 
“NSTableCellView” never passed). I also had to change the font in the delegate 
call I already had for row-height calculation.

> Note that if you want to reference subviews of the cell view via outlets, 
> you’ll need to subclass NSTableCellView to add the outlets. Then you can 
> connect them from the cell view prototype in IB to individual UI elements. 
> (The standard outlets “text” and “image” work the same way, but you get them 
> for free on NSTableCellView. )
> 
> Alternatively, if you subclass NSTableCellView, you can override 
> “prepareForReuse”, which would allow you to configure subviews without having 
> to put the code in the delegate method.

I first tried overriding “prepareForReuse” in my text-field subclass, but it 
never stuck.

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to