I am working on my first native mac app after playing with iOS for a while.
I am attempting to launch a window from a menu item, but I suspect I am doing it wrong. Any IBAction
I connect to buttons on this new window returns an error.
Here is what I am doing. From a menu item I launch this:
-(IBAction)displaySAInput:(id)sender{
NSLog(@"Input selected.");
inputSAViewController = [[NSWindowController alloc] initWithWindowNibName:@"InputViewController"];
[inputSAViewController showWindow:self];
This launches the InputViewController
nib that is owned by the InputViewController
class. I set the InputViewController
class to inherit from NSWindowController
.
On InputViewController.m
I have tested IBAction
s such as:
-(IBAction)testButton:(id)sender{
NSLog(@"Data recalled?");
}
I connect this IBAction
to a button through the Interface Builder. All looks okay.
When I build and open the InputViewController
window I receive this error in the console before clicking anything:
Could not connect the action testButton: to target of class NSWindowController
I have searched extensively but my ignorance prevents me from connecting the dots. This thread based on a similar error with NSApplication looks promising, but I don't quite understand what I'd need to make the connections happen related to the NSWindowController
error.
This should be simple. What am I missing?