Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

satyam90

macrumors regular
Original poster
Jul 30, 2007
242
0
Bangalore, India
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?
 
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).
 
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,
 
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:

Code:
- (void)awakeFromNib {
    [[NSNotificationCenter defaultCenter] addObserver:self
        selector:(tableViewSelectionDidChange:)
        name:NSTableViewSelectionDidChangeNotification
        object:myTableView];
}

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

You will need an IBOutlet to your NSTableView.
 
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?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.