我在確定如何分辨哪個對象發佈的通知的麻煩。確定哪個對象發佈通知?
予訂閱通知在對象A:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedNotification:) [email protected]"ReceivedData" object:nil]
我發佈通知從對象B:
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReceivedData" object: self userInfo: dict];
我收到該通知中對象A:
- (void) receivedNotification: (NSNotification*) notification
{
// Method is hit fine, notification object contains data.
}
我怎麼能知道它是對象B發送的數據而不是,例如,一個對象C?我需要對發件人的引用。我不想將發件人添加到正在傳遞的通知對象,因爲我在撥打對象時指定發件人B
這正是我想要檢索的內容。我如何在通知的接收者中獲得該信息?你可以看到我的問題,發佈通知的類包括object:self。 – 2011-06-03 16:51:09
在通知參數上調用'object'方法。 – albertamg 2011-06-03 16:53:51