问题描述
我想观察对日历应用程序的更改,因此我注册了 EKEventStoreChangedNotification
通知。但是我需要一个 EKEventStore
对象alive来接收这个通知吗?我想我在视图控制器中初始化 EKEventStore
对象来检索一些事件。然后我将弹出这个视图控制器的导航堆栈和视图控制器将被释放,因此 EKEventStore
对象将被释放。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(storeChanged :)
name:EKEventStoreChangedNotification object:eventStore];
请参阅 以便更清楚地了解您的疑问
I want to observe changes to the Calendar application so I register for the EKEventStoreChangedNotification
notification. But do I need to have an EKEventStore
object "alive" for me to receive this notification? I'm thinking I'm initializing the EKEventStore
object in on view controller to retrieve some events. And then I will pop this view controller of the navigation stack and the view controller will be deallocated thus the EKEventStore
object will be deallocated.
No, you don't need to keep the EKEventStore object alive as you are already registering EKEventStoreChangedNotification using EKEventStore object named eventStore
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(storeChanged:)
name:EKEventStoreChangedNotification object:eventStore];
Refer this for more clearance of your doubt
这篇关于iOS - Event Kit编程监听通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!