【问题标题】:iOS: Save which is the preferred EKCalendar some how?iOS:如何保存首选的 EKCalendar?
【发布时间】:2013-03-03 17:53:32
【问题描述】:

我正在构建一个小型日历应用程序,用户可以在其中选择应输入事件的日历。因此,用户从设置模式中的选择器视图中选择他们选择的日历,然后当他们输入新事件时,我应该能够获取该日历对象以某种方式创建事件。我尝试将对象写入 plist,将其放入 NSDictionary 中,但我认为它无法存储该类型的对象。我可以保存日历的名称和日历类型并以某种方式获取带有这两个参数的 EKCalendar 对象吗?最好不必手动遍历它们。

另外,我如何以编程方式创建新的日历事件?我有关于每个事件的以下信息;开始时间是现在,结束时间是从起点开始的分钟值,如果是一整天,日历(如果我可以让最高位工作)和事件名称。

提前致谢, 克里斯托弗。

【问题讨论】:

    标签: ios calendar eventkit


    【解决方案1】:

    我建议你先阅读EventKit Programming Guide。它解释了如何创建和保存新事件。

    如果您想保存有关所选日历的信息并稍后从该信息中检索日历,您可以将EKCalendarcalendarIdentifier 属性与-calendarWithIdentifier:-calendarWithIdentifier: 方法结合使用:

    // Save the identifier
    NSString *identifier = [aCalendar calendarIdentifier];
    ...
    
    // Retrieve the calendar later
    NSString *identifier = ...;
    EKCalendar *aCalendar = [eventStore calendarWithIdentifier:identifier];
    

    EKCalendar Class Reference
    EKEventStore Class Reference

    【讨论】:

    • 谢谢,这正是我想要的!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-01
    • 2015-06-11
    • 1970-01-01
    • 2021-01-17
    • 2012-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多