ios - 将 EKEvent 保存到 EKEventStore 时出错(导出到日历)
问题描述
我的自动报告在导出到用户日历时显示了一个日益严重的问题,并出现错误:
NSInternalInconsistencyException
Trying to set the object ID on an object that has one!
当我打电话时
do {
try store.save(event, span: .thisEvent)
return event.eventIdentifier
} catch {
Log.error(error.localizedDescription)
}
我目前很难重现该错误,甚至无法在线找到任何开放主题。它似乎发生在 iOS 14 上。有人遇到过吗?有什么建议么?
解决方案
我有同样的问题,我找到了解决方案。在主线程中进行 store.save 。
DispatchQueue.main.async {
do {
try self.eventStore.save(event, span: .thisEvent)
} catch let error as NSError {
print("failed to save event with error : \(error)")
}
}
推荐阅读
- python-3.x - 我可以阅读我已经在 Xlsxwriter 的单元格中写的内容吗?
- android - 我正在尝试将我的 Android 项目连接到 Firebase 实时数据库,但它总是失败。请帮我找出错误是什么
- vuejs2 - 如何删除双引号?
- php - Pjax 在 Yii2 上的 gridview 搜索上重新加载页面
- c++ - 字符串不会在拆分时更新其值
- java - 如何在 Intelli J 中设置 JAVA_HOME 环境变量
- javascript - 谷歌地图中的滑动标记给出错误谷歌未定义
- angular - 将html表导出到excel Angular 6
- sqlite - Xamarin Forms:如何按时间排序从本地数据库中选择所有项目
- android - 为什么Scrollview在drawerlayout下不起作用