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;
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.
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 :-)
But it does seem to be a bug - I just checked iCal on my Mac and it's loaded up with duplicate calendars.
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.
Something like this:
I think that works. Just doing some more testing at the moment.
If the Cal doesnt exist I'm getting the default source with something like this:
Hope that helps.