我很新于Objective C,并且以前没有用过MVC系统。
我正在尝试通过默认浏览器重定向到一个URL,这是相关的代码:
AppDelegate.h
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
...
- (IBAction)about:(id)sender;
...
@end
声明操作
AppDelegate.m
@implementation AppDelegate
...
- (IBAction)about:(id)sender {
NSURL *web_url = [NSURL URLWithString:@"http://www.someurl.com/"];
[[NSApplication sharedApplication] openURL:web_url]; // error location
}
...
@end
关于在按钮点击时实现操作:
IDE错误:NSApplication没有声明openURL选择器的可见@interface
问题似乎是什么?
IBAction
?你应该将IBAction
放在视图控制器/视图中。 - Raptor