添加CFNotificationCenter观察者为NULL时,如何删除

时间:2019-08-27 10:11:10

标签: ios core-foundation

因此,在iOS平台上,我看到多个有关CFNotificationCenterAddObserver的示例,其中将observer参数设为NULL,例如

CFNotificationCenterAddObserver(center, NULL, notificationCallback, 
                                    CFSTR("MyNotification"), NULL, 
                                    CFNotificationSuspensionBehaviorDeliverImmediately);

医生说

  

观察者

     

观察者。在macOS 10.3和更高版本中,此参数可能为NULL。

但是,在CFNotificationCenterRemoveObserver()CFNotificationCenterRemoveEveryObserver()中,是

  

观察者

     

观察者。此值不能为NULL。

所以我有些困惑,如果我的观察者为NULL,我应该在我的dealloc方法中调用CFNotificationCenterRemoveEveryObserver()吗?如果是这样,我应该为观察者传递什么,仍然为NULL?

0 个答案:

没有答案