使用EventKit将新日历添加到EKEventStore [英] Add a new calendar to an EKEventStore with EventKit

查看:248
本文介绍了使用EventKit将新日历添加到EKEventStore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iOS 5中将日历(而不是事件)添加到EKEventStore?

解决方案

除非我也这样做:

  //获取日历源
EKSource * localSource;
for(EKSource * source in eventStore.sources){
if(source.sourceType == EKSourceTypeLocal)
{
localSource = source;
break;
}
}

if(!localSource)
return;

calendar = [EKCalendar calendarWithEventStore:eventStore];
calendar.source = localSource;

当然,看看其他EKSourceType枚举,看看哪一个是适合你的需要。 / p>

How can I add a Calendar (not an event) to a EKEventStore in iOS 5?

解决方案

I caught an exception unless I also did:

// Get the calendar source
EKSource* localSource;
for (EKSource* source in eventStore.sources) {
    if (source.sourceType == EKSourceTypeLocal)
    {
        localSource = source;
        break;
    }
}

if (!localSource)
    return;

calendar = [EKCalendar calendarWithEventStore:eventStore];
calendar.source = localSource;

Naturally, take a look at the other EKSourceType enums to see which one is appropriate for your needs.

这篇关于使用EventKit将新日历添加到EKEventStore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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