保存多个Google日历事件时缺少EKEvents [英] Missing EKEvents when saving multiple Google calendar events

查看:62
本文介绍了保存多个Google日历事件时缺少EKEvents的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在遍历约100个对象,这些对象使用EventKit为每个对象创建一个事件.在保存所有对象并知道为每个对象成功获取calendarIdentifier之前,我不会提交".但是,约有10-15%的事件从未显示在设备日历或在线上.这仅在Google日历中发生.iCloud和本地工作正常.

I'm looping through around 100 objects that create an event for each using EventKit. I don't "commit" until all the objects are saved and know a calendarIdentifier is successfully fetched for each. Yet about 10-15% of the events never show on the device calendar or online. This only happens with Google Calendar. iCloud and local work fine.

我了解在创建多个这样的事件时,最好使用:

I understood when creating multiple events like this, it was preferable to use:

[eventStore saveEvent:event span:EKSpanThisEvent commit:NO error:&error];

...和

[eventStore commit:&error];

...在创建所有事件之后.我还尝试在每个循环中进行提交,并且可以预见的是,通讯被中断时出现了错误.感谢任何帮助.

...after all events have been created. I also tried committing through each loop and predictably got errors around communication being interrupted. Appreciate any help.

推荐答案

我遇到了类似的问题.当我删除EKEvent实例,然后立即保存新的EKEvent实例时,会发生我的问题.有时(可能是5分之3),再次出现已删除的事件.删除未返回任何错误.对我来说,它似乎未成功提交,然后EKEventStore自行回滚了应删除"事件.我尝试了所有不同的方式来处理该过程,例如,将提交设置为是"或否",再次请求访问并且仅授予访问权限为是",然后启动该过程.但是没有区别.我花了几个晚上试图弄清楚是什么原因造成的,但毫无头绪.

I met similar problem. My issue happens when I delete an EKEvent instance, then save a new EKEvent instance immediately. Sometimes (maybe 3 out of 5), the deleted event appears again. The deletion did not return any error. For me, it looks like it did not submit successfully, then the EKEventStore rolled back that "should be deleted" event by itself. I tried all different ways to handle the processing, for example, with the commit set to Yes or No, request access again and only access granted is Yes then start the process. But there is no difference. I spent several nights trying to figure out what caused that but had no clue.

然后,我将已删除的EKEvent的eventIdentifier添加到数组中,并再次进行验证(就在获取事件之前).如果仍然存在,请再次将其删除.到目前为止,它运作良好.这是一个肮脏的解决方案,但至少可以奏效.

Then I added the deleted EKEvent's eventIdentifier to an array and verify a second time (just before I fetch events). If it is still there, delete it again. So far it works well. It's a dirty solution but at least it works.

因此,我建议其他用户在使用EventKit对Google日历进行批处理操作时,尝试类似的解决方案.在下一次提取之前,请再次检查eventIdentifiers.如果某些eventIdentifiers应该存在或不应存在(使用[EKEventStore eventWithIdentifier]),请再次添加或删除它.

So I suggest other users try similar solutions when they do batch operations with Google Calendars using EventKit. Check again the eventIdentifiers before next fetch. If some eventIdentifiers should be or should not be there (using [EKEventStore eventWithIdentifier]), add it again or delete it again.

只有我的2美分.

这篇关于保存多个Google日历事件时缺少EKEvents的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆