iOS - Event Kit编程监听通知 [英] iOS – Event Kit programming listen to notifications

查看:163
本文介绍了iOS - Event Kit编程监听通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想观察对日历应用程序的更改,因此我注册了 EKEventStoreChangedNotification 通知。但是我需要一个 EKEventStore 对象alive来接收这个通知吗?我想我在视图控制器中初始化 EKEventStore 对象来检索一些事件。然后我将弹出这个视图控制器的导航堆栈和视图控制器将被释放,因此 EKEventStore 对象将被释放。

eventStore 的EKEventStore对象注册EKEventStoreChangedNotification



  [[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编程监听通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆