【问题标题】:App crash while retrieve event with Identifier from calendar使用日历中的标识符检索事件时应用程序崩溃
【发布时间】:2017-05-16 07:20:16
【问题描述】:

当用户从日历中手动删除事件并且应用尝试从 EKEventStore 检索带有标识符的 EKEvent 时,应用会因以下错误而崩溃。

获取标识符为 AB78AC19-BD17-4290-8A21-4BF948089C12:66F6F5BC-BF61-401A-B808-44A555F7E63E 的事件时出错: 错误域=EKCADErrorDomain Code=1010 "无法进行操作 完全的。 (EKCADErrorDomain 错误 1010。)“致命错误:意外 在展开可选值时发现 nil

这是用于获取带有标识符的事件的代码

let eventStore = EKEventStore()
let event = eventStore.event(withIdentifier: identifier as String)!

请帮帮我。

【问题讨论】:

    标签: ios swift calendar ekevent ekeventstore


    【解决方案1】:

    检查事件是否存在:

    let eventStore = EKEventStore()
    if let event = eventStore.event(withIdentifier: identifier as String) {
        //do what you need with the event
    }
    

    【讨论】:

      猜你喜欢
      • 2019-03-11
      • 2016-02-11
      • 2017-06-22
      • 1970-01-01
      • 1970-01-01
      • 2021-12-13
      • 1970-01-01
      • 1970-01-01
      • 2016-02-17
      相关资源
      最近更新 更多