嘿,那麼我有一個NSObject子類通過通知中心發送消息,並且我將通知發送給對象nil,但唯一的對象是收到通知是一個向他們發送NS通知只在同一個對象內發送
我有兩個通知在同一時間被髮送出去(以測試它是否是一個線程問題)
[[NSNotificationCenter defaultCenter] postNotificationName:kWGAskingForAuthToken object:nil];
int status = 123;
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"RAR" forKey:@"Status"];
NSNotification *note = [NSNotification notificationWithName:kWGAskingForAuthToken object:nil userInfo:userInfo];
[[NSNotificationCenter defaultCenter] performSelectorOnMainThread:@selector(postNotification:) withObject:note waitUntilDone:YES];
,我的觀察是一樣簡單
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMyEvent:)name:kWGAskingForAuthToken object:nil];
這是在不接收通知的單獨對象中的相同觀察者
恐怕是正確定義(因爲它們都已經包括一個NSString常數) 是什麼使得它有點令人沮喪的是,我有一個日誌通過回聲出數百個,但從來沒有我自己 中心全力以赴通知 ([[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(log :) name:nil object:nil];) – orta 2010-07-15 10:32:55