1

我在创建日历时遇到问题,我已从 iCloud 注销以删除所有其他合并的日历。现在,只剩下 Gmail 和 yahoo 日历,而 gmail 是我的默认日历。我想创建自己的日历并将其标记为默认但不能。

我用它eventStore.defaultCalendarForNewEvents.source来为我新创建的日历分配源并得到一些像这样的错误

“此来源不允许编辑内容等。”

虽然这段代码返回 trueprint(eventStore.defaultCalendarForNewEvents.allowsContentModifications)

有没有创建自己的方法,因为我们可以看到其他应用程序,即谷歌、雅虎等已经创建了自己的。这是创建新日历的代码

let newCalendar = EKCalendar(for: .event, eventStore: eventStore)
 newCalendar.title = "Test Calendar"

    do {
         newCalendar.source = eventStore.defaultCalendarForNewEvents.source
        try eventStore.saveCalendar(newCalendar, commit: true)
    } catch {
              let alert = UIAlertController(title: "Calendar could not save", message: error.localizedDescription, preferredStyle: .alert)
              let OKAction = UIAlertAction(title: "OK", style: .default, handler: nil)
              alert.addAction(OKAction)

              self.present(alert, animated: true, completion: nil)
    }

谢谢

4

0 回答 0