Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 25, 2008, 06:14 AM   #1
satyam90
macrumors regular
 
Join Date: Jul 2007
Location: Bangalore, India
Send a message via Yahoo to satyam90
Panel & Delegate methods of its controls

Hi, I am having a NSTableView inside a panel. I implemented "- (void)tableViewSelectionDidChangeNSNotification *)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?
satyam90 is offline   0 Reply With Quote
Old Mar 25, 2008, 07:13 AM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
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).
kainjow is offline   0 Reply With Quote
Old Mar 26, 2008, 01:31 AM   #3
satyam90
Thread Starter
macrumors regular
 
Join Date: Jul 2007
Location: Bangalore, India
Send a message via Yahoo to satyam90
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,
satyam90 is offline   0 Reply With Quote
Old Mar 26, 2008, 06:53 AM   #4
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
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.
kainjow is offline   0 Reply With Quote
Old Apr 1, 2008, 10:45 PM   #5
satyam90
Thread Starter
macrumors regular
 
Join Date: Jul 2007
Location: Bangalore, India
Send a message via Yahoo to satyam90
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?
satyam90 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
UIScrollView delegate methods not called. zaxonus iPhone/iPad Programming 1 Jan 4, 2013 12:38 AM
Skype Desktop API delegate methods doesn't get called on Mac OSX saqibjaan Mac Programming 0 Nov 16, 2012 12:31 AM
What are the best methods & software to test new Hard Drives before using for work? sngraphics Mac Pro 1 Nov 6, 2012 10:25 AM
How to check Audio & MIDI Plug-Ins, Drivers, Input Methods, etc. for Compatibility? Dark Goob OS X 10.8 Mountain Lion 4 Aug 28, 2012 09:19 PM
Class methods vs instance methods zijianz iPhone/iPad Programming 8 Jul 20, 2012 11:15 AM

Forum Jump

All times are GMT -5. The time now is 09:54 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC