自定义EKSourceType -事件套件iOS /只读日历



我试图创建一个calendar,显示在Apple's calendar(从我的应用程序),但我希望它是只读的(只能从我的应用程序编辑,而不是双向同步到Apple's calendar系统)-我希望使用EKSourceTypeSubscribed将为此工作,并使用此代码:

    EKSource *theSource = nil;
    for (EKSource *source in store.sources) {
        if (source.sourceType == EKSourceTypeSubscribed) {
            theSource = source;
            break;
        }
    }

尝试检索相关的EKSource(因为似乎没有办法创建新源)。但是,除非用户已经订阅了一些日历,否则这个源类型似乎不存在。

任何想法?

没有EventKit日历的概念,它的事件你可以修改,但不能从本地日历应用程序修改(或从任何第三方日历管理应用程序,就这一点而言)。

EKSourceTypeSubscribed创建的日历不是只读的,即使您可以可靠地找到源类型。
EKCalendar *theCal = [EKCalendar calendarForEntityType:EKEntityTypeEvent eventStore:self.eventStore];
theCal.source = theSource; // per your source selection snippet above
NSLog(@"isImmutable %d, allowsContentModifications %d", [theCal isImmutable], [theCal allowsContentModifications]);

搜索结果

isImmutable 0, allowsContentModifications 1

最新更新