EKEventKit过期事件已添加到模拟器中,但未添加到swift中的设备上



我正在使用EKEventKit将事件添加到日历中。设备上只存储今天的事件,而不存储过去的事件。但它是在模拟器上添加的。

以下是我的代码:

    func createEvent(eventStore: EKEventStore, title:String, startDate: NSDate, endDate: NSDate){
        let event = EKEvent(eventStore: eventStore)
         event.title = title
        event.startDate = startDate // contains september 2015 date
        event.endDate = startDate
        event.availability = EKEventAvailability.Free
        event.calendar = eventStore.defaultCalendarForNewEvents
        do{
            try eventStore.saveEvent(event, span: .ThisEvent)
//            JLToast.makeText("Event added successfully").show()
        } catch {
        }
    }

我哪里错了?我该如何解决此问题?

我刚刚遇到了完全相同的问题。解决方案是在Settings.app->邮件、联系人、日历->日历部分->同步到所有事件中更改设备设置。同样在我的情况下,我在更改此设置之前尝试创建的所有事件都会在之后出现在Calendar.app中。

不过,我还没有找到从代码中检查此设置的方法。

最新更新