Re: Newbie delegate question regarding NSTable

On Mar 25, 2009, at 08:53, Todd Fantz wrote:

I have a NSTable bound to an object and have written delegate methods in the object for numberOfRowsInTableView and objectValueForTableColumn and those are being called as expected no problem. I am trying to color rows/cells based on the data in the table and so I put in a willDisplayCell method but it just isn't being called/fired. I have put breakpoints and NSLog statements and it just isn't happening. Anything possible causes come to mind? Do I need to do anything more than the nib binding and define the method in the object.m to get this called?

Do you mean the "tableView:willDisplayCell:forTableColumn:row:" delegate method? If so, it's worthwhile being that precise in your question so that we know that (for example) you didn't just use the wrong method name by accident. (That actually happens a lot.)

In your case:

1. 'numberOfRowsInTableView:' and 'tableView:objectValueForTableColumn:row:' are *data source* methods, not delegate methods. (Well, the data source is a kind of delegate, but not *the* delegate of the table view.)

2. 'tableView:willDisplayCell:forTableColumn:row:' is a delegate method (that is, a method of *the* delegate). Most likely, the reason it's not being called is that you haven't specified the table view's delegate. If you look at the table view in IB, you'll see that there's a data source connection and a delegate connection. Make sure each is connected to the appropriate object.

3. It sounds like you don't really have a binding from the table view, but rather a connection from the table view to its data source. (Bindings are something else altogether.)


Cocoa-dev mailing list (Cocoa-dev@xxxxxxxxxxxxxxx)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)


be/Update your Subscription:

This email sent to maillists@xxxxxxxxx