我在确定如何分辨哪个对象发布的通知的麻烦。确定哪个对象发布通知?
予订阅通知在对象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