相关疑难解决方法(0)

当postNotificationName:调用时,不发送NSNotification

我试图让使用的一个实例NSNotificationCenteraddObserverpostNotificationName,但我不能工作了,为什么它不会工作.

我有2行代码来添加观察者并在2个不同的类中发送消息

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(newEventLoaded:) name:@"Event" object:nil];
Run Code Online (Sandbox Code Playgroud)

[[NSNotificationCenter defaultCenter]postNotificationName:@"Event" object:self];
Run Code Online (Sandbox Code Playgroud)

如果我将名称设置为nil它工作正常,因为它只是一个广播,当我尝试定义通知名称时,消息永远不会通过.

iphone objective-c nsnotificationcenter

14
推荐指数
4
解决办法
3万
查看次数

标签 统计

iphone ×1

nsnotificationcenter ×1

objective-c ×1