【发布时间】:2012-09-01 11:10:05
【问题描述】:
在玩了一段时间 iOS 之后,我正在开发我的第一个原生 mac 应用程序。
我试图从一个菜单项启动一个窗口,但我怀疑我做错了。任何IBAction 我连接到这个新窗口上的按钮都会返回错误。
这就是我正在做的事情。从一个菜单项我启动这个:
-(IBAction)displaySAInput:(id)sender{
NSLog(@"Input selected.");
inputSAViewController = [[NSWindowController alloc] initWithWindowNibName:@"InputViewController"];
[inputSAViewController showWindow:self];
这将启动 InputViewController 类拥有的 InputViewController nib。我将InputViewController 类设置为继承自NSWindowController。
在InputViewController.m我已经测试过IBActions 比如:
-(IBAction)testButton:(id)sender{
NSLog(@"Data recalled?");
}
我通过 Interface Builder 将此 IBAction 连接到一个按钮。一切看起来都很好。
当我构建并打开 InputViewController 窗口时,我在控制台中收到此错误,然后单击任何内容:
Could not connect the action testButton: to target of class NSWindowController
我进行了广泛的搜索,但我的无知使我无法将这些点联系起来。这个线程based on a similar error with NSApplication 看起来很有希望,但我不太明白我需要什么才能使与NSWindowController 错误相关的连接发生。
这应该很简单。我错过了什么?
【问题讨论】:
标签: objective-c macos cocoa