iOS – Event Kit编程监听通知

标签 ios cocoa-touch eventkit

我想观察日历应用程序的更改,因此我注册了 EKEventStoreChangedNotification 通知。但是我是否需要有一个“事件”的 EKEventStore 对象才能接收此通知?我想我正在初始化 View Controller 中的 EKEventStore 对象来检索一些事件。然后我将弹出导航堆栈的此 View Controller ,并且 View Controller 将被释放,因此 EKEventStore 对象将被释放。

最佳答案

不,您不需要保持 EKEventStore 对象处于事件状态,因为您已经使用名为 eventStore 的 EKEventStore 对象注册 EKEventStoreChangedNotification

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(storeChanged:)
                              name:EKEventStoreChangedNotification  object:eventStore];

引用this进一步消除您的疑虑

关于iOS – Event Kit编程监听通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12323796/

相关文章:

ios - MPMoviePlayerController View 未调整大小

ios - Swift 4.2 EventKit 将所有事件获取到 TableView didSelectedRowAt 上的选定日历

ios - 无法在 iPhone X Swift 中获取当前位置

ios - 时间比较不起作用。有什么问题吗?

iOS XMPP vs WebRTC,我应该使用哪个?

ios - 始终将 NSData 保存到同一个文件

iphone - 如何从 iPhone 应用程序中启动 iPhone 日历?

ios - 我怎样才能在我的应用程序上吸收应用程序日历 [iOS]

ios - "' ViewController.Type ' does not have a member named . . . "

objective-c - NSNotification : does the object property have to be self?