3
我是一名體驗C/C++程序員,但新的ObjC++。我試圖在Mac OSX項目中捕獲NSWorkspacedidmountnofification。NSWorkspacedidmountNotify /可能通用NSWorkspace
我將我的回調添加到我的應用程序委託界面。
- (void)mediaMounted:(NSNotification *)notification;
實現包括
- (void)mediaMounted:(NSNotification *)aNotification {
NSLog(@"mediaMounted volume change.");
}
在我的applicationDidFinishLaunching,我自己添加到通知中心。
NSNotificationCenter* ncenter = [[NSWorkspace sharedWorkspace] notificationCenter];
[ncenter addObserver: self
selector: @selector(mediaMounted)
name: NSWorkspaceDidMountNotification
object: nil];
然而,當我運行和安裝盤,我看到:
2012-08-29 09:52:31.753 OSN[2203:903] -[OSNAppDelegate mediaMounted]: unrecognized selector sent to instance 0x101340af0
2012-08-29 09:52:31.756 OSN[2203:903] -[OSNAppDelegate mediaMounted]: unrecognized selector sent to instance 0x101340af0
我證實,實例0x101340af0是我OSNAppDelegate自我,但我不明白還有什麼我必須這樣做選擇器被識別。