从应用程序创建日历时的iCloud日历同步问题 [英] iCloud calendar synchronization issue while creating calendar from application

查看:214
本文介绍了从应用程序创建日历时的iCloud日历同步问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试为iOS实施iCloud Calendar同步。
我的想法是从我的应用程序创建一个新日历,并在实际启用iCloud同步时与iCloud同步。
要获得相应的来源,我使用以下代码:

Trying to implement iCloud Calendar synchronization for iOS. The idea is to create a new calendar from my app and sync it with iCloud when iCloud sync is on actually. To get corresponding source I'm using the following code:

EKSource * localSource = nil;

EKSource* localSource=nil;

for(EKSource * source in self.eventStore.sources)
{
if(source.sourceType == EKSourceTypeCalDAV&& [source.title isEqualToString:@iCloud])
{
localSource = source;
休息;
}

for (EKSource* source in self.eventStore.sources) { if(source.sourceType == EKSourceTypeCalDAV && [source.title isEqualToString:@"iCloud"]) { localSource = source; break; }

}

然后在该来源中创建日历并保存。

Then creating a calendar in that source and saving.

当iCloud同步开启且iCloud的日历同步也开启时,从iPhone->设置 - > iCloud->日历它工作得很好。
理论上,从上述设置关闭日历同步后,它不应再允许在该商店中创建日历。但实际上甚至在这种情况下它允许从我的应用程序获得相应的iCloud存储并创建/保存新日历。
创建新日历后,它不会在iPhone的日历列表中显示。但是当您登录iCloud Web界面时,您可以看到许多与您刚刚添加的名称相同的日历。具有该名称的日历的数量越来越多。像这样的接缝在iCloud的日历同步中存在无限循环问题。到目前为止这样的接缝是一个iOS问题,无法在任何地方找到任何报告。

When iCloud sync is on and Calendar synchronization is on for iCloud as well from iPhone->Settings->iCloud->Calendar It's working just fine. After switching off calendar synchronization from above mentioned settings theoretically it should not allow to create calendar in that store any more. But actually even in that case it allows to get corresponding iCloud store from my application and create/save a new calendar. After creating a new calendar it's not showing it in iPhone's calendars list. But when you logging in to the iCloud web interface you can see there a lot of calendars with the same name that you have just added. The number of calendars with that name is getting more and more. Seams like there is an infinite loop problem in calendar synchronization for iCloud. So far seams like it's an iOS problem and could not find any report on that anywhere.

推荐答案

不确定你是否想出这个问题,如果你这样做,发布你的解决方案: - )

Not sure if you figured this out, if you did, post your solution :-)

但它似乎确实是一个错误 - 我只是检查了我的Mac上的iCal,它加载了重复的日历。

But it does seem to be a bug - I just checked iCal on my Mac and it's loaded up with duplicate calendars.

只是搞清楚,但我认为我工作的一些粗略代码是在EKSource中创建一个日历,然后检查该日历。

Just figuring it out, but some rough code I think I have working is to create a Calendar in the EKSource and then check for that Calendar.

这样的事情:

-(BOOL)testCal {
  BOOL cal = 0;

  NSUInteger counter = 1;
  for (EKCalendar *thisCalendar in [[DGEK eventStore]calendars] ){
    NSLog(@"%@", thisCalendar.title);
    if ([thisCalendar.title isEqualToString:@"YourCalName"]) {
        cal = YES;
        return cal;
    }
    counter++;
  }
  return cal; 
}

我认为这样有效。现在只做一些测试。

I think that works. Just doing some more testing at the moment.

如果Cal不存在,我会得到这样的默认来源:

If the Cal doesnt exist I'm getting the default source with something like this:

source = [[[self eventStore] defaultCalendarForNewEvents] source];

希望有所帮助。

这篇关于从应用程序创建日历时的iCloud日历同步问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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