View Full Version : Panel & Delegate methods of its controls

Mar 25, 2008, 06:14 AM
Hi, I am having a NSTableView inside a panel. I implemented "- (void)tableViewSelectionDidChange:(NSNotification *)aNotification".
But I noticed that it is not called at all even though I am changing the table view's items. Can anyone tell me why this is happening? How to make the delegate called inside a Panel?

Mar 25, 2008, 07:13 AM
So your table view is inside an NSPanel, and the tableViewSelectionDidChange: notification is not being called? Are you sure your delegate is properly setup? You could also try subscribing to the NSTableViewSelectionDidChangeNotification notification manually (especially if you're using bindings).

Mar 26, 2008, 01:31 AM
Hi Kainjow,
I didn't set the delegate. I implemented "- (void)tableViewSelectionDidChangeNSNotification *)aNotification" in the controller of the panel.
Can you please some reference how to handle this.
Also can u tell me how to subscribe to notification manually.
Thanks & Regards,

Mar 26, 2008, 06:53 AM
tableViewSelectionDidChange: gets called only in 2 situations:

1) you set the NSTableView delegate
2) you added your class as an observer of the NSTableViewSelectionDidChangeNotification notification

So if you didn't do 1, you need to do 2:

- (void)awakeFromNib {
[[NSNotificationCenter defaultCenter] addObserver:self

- (void)tableViewSelectionDidChange:(NSNotification *)notification {
// yay it changed

You will need an IBOutlet to your NSTableView.

Apr 1, 2008, 10:45 PM
Hi Kainjow,
The second option is working fine but not the first one.
For first option, in IB, I selected table view control and then associated its delegate to my controller class where I implemented textDidChange. Do I have to include or change anything for that?