0
Settting了觀察者代碼:無法獲得可可通知工作
NSNotificationCenter *defaultCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
[defaultCenter addObserver:self
selector:@selector(updateLog:)
name:@"Update Log"
object:nil];
發送通知代碼:
[[NSNotificationCenter defaultCenter] postNotificationName:@"Update Log" object:self];
利用該方法定義爲:
-(void)updateLog: (NSNotification *) notification {
NSLog(@"Update Log"); }
文本「更新日誌「在通知發送時不會出現在日誌中。 感謝任何想法,爲什麼此代碼無法正常工作。
我討厭增加噪音,因爲我在OS X上不是Cocoa的專家,但是您確定共享工作區的通知中心與默認通知中心相同嗎? – warrenm 2010-09-15 01:26:55