【发布时间】:2010-01-21 22:29:54
【问题描述】:
我正在尝试使用 NSNotificationCenter 与 addObserver 和 postNotificationName 的一个实例,但我不知道为什么它不起作用。
我有 2 行代码来添加观察者并在 2 个不同的类中发送消息
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(newEventLoaded:) name:@"Event" object:nil];
和
[[NSNotificationCenter defaultCenter]postNotificationName:@"Event" object:self];
如果我将名称设置为nil,它可以正常工作,因为它只是一个广播,当我尝试定义一个通知名称时,消息永远不会通过。
【问题讨论】:
标签: iphone objective-c nsnotificationcenter