本地EKCalendar保存没有错误,消失 [英] Local EKCalendar saved with not errors, disappears
问题描述
我尝试使用 EKSourceTypeLocal
来创建日历。迭代 self.eventStore.sources
,找到一个 sourceType == .Local
并尝试创建一个新的日历与它。
I'm trying to create a calendar with EKSourceTypeLocal
source. Iterate over the self.eventStore.sources
, find the one with sourceType == .Local
and attempt to create a new calendar with it.
self.calendar = EKCalendar(forEntityType: EKEntityType.Event, eventStore: self.eventStore)
self.calendar?.title = "My Awesome Calendar"
self.calendar?.source = src // src.sourceType == .Local
print("Created \(self.calendar!)")
do {
try self.eventStore.saveCalendar(self.calendar!, commit: true)
} catch let err as NSError {
print("Whoops: \(err)")
}
执行没有问题,并允许我添加一些事件到该日历以及。然而,当我切换到本地日历应用程序,这个新的没有,如果我查询 self.eventStore.calendarsForEntityType(EKEntityType.Event)
上述完成后,它也不在那里,如果我重新启动应用程序,我创建的日历和所有的事件无处可找。发生了什么?
That executes without a problem, and allows me to add some events to that calendar as well. However, when I switch to the native Calendar app, this new one is no there, if I query self.eventStore.calendarsForEntityType(EKEntityType.Event)
after the above has completed, it's not there either, and if I restart the app, the calendar I created and all its events are nowhere to be found. What's happening?
推荐答案
如果您的设备上有其他来源的日历,则 EKSourceTypeLocal
If you have calendars from other sources active on your device, calendars of type EKSourceTypeLocal
will not be visible in the Apple Calendars app.
此外,当其他日历来源处于活动状态时,活动存储将不会显示本地日历。
Additionally, the event store will not show the local calendar when other calendar sources are active.
如果您停用其他日历,则应该可以在日历应用和事件存储中查看已保存的本地日历。
If you de-activate the other calendars, you should be able to see the saved local calendar in both the Calendars app and the event store.
我假设你的应用程序具有使用 requestAccessToEntityType:completion:
获得必要的权限。
I’m assuming your app has the necessary permissions obtained using requestAccessToEntityType:completion:
.
这篇关于本地EKCalendar保存没有错误,消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!