How to decide if the EKCalendar can be hidden by default?

I am writing an application that deals with calendars. In the application, I show a list of all available calendars to enable or disable the user. I do not use the EventKitUI for the purposes of my own design and user interface.

I get a neat list of calendars by polling the calendars property of an EKEventStore . However, on my device there is an EKCalendar object in this list that is not displayed by EKEventKitUI . This is the description of the object in the debugger:

 EKCalendar <0xcea6b60> {title = Agenda; type = Local; allowsModify = YES; color = #711A76;} 

I launch my iPhone in Dutch, so the name is "Agenda" and not "Calendar", but if you launch the iPhone in English, you will see. This appears to be the default calendar for iOS, but since I have all my calendars configured to sync with iCloud, it is disabled for the built-in calendar applications. I also want to disable it in my application, but I do not know how to do it.

From looking at the properties of EKCalendar I can’t distinguish one to decide which calendar I need to β€œhide”. There's a type property that is "local" to this standard calendar, but if someone is not using iCloud, I think that all calendars are of local type. subscription is not it either, equal allowsContentModifications . I saw examples of people hiding the default calendar based on its name , but as you can see, the name is localized and therefore very impractical, this is simply wrong.

Which trick to decide which calendar is the default calendar and hide it or not to match the list of calendars displayed by your regular iCal / Calendar application?

EDIT:. Although the question has been marked as an answer, the answer contains a big "no, you cannot." I solved this problem for my users by adding the settings panel switch to "Hide local calendars", but this is a very, very difficult solution.

+7
source share
1 answer

To answer your question in bold, there is no magic property that you can use to determine if a calendar should be hidden or displayed.

However, if your theory is correct about the Calendar application hiding the "local" calendar, if other types of calendars are available (iCloud / MobileMe, Exchange, CalDAV, etc.), then you can reflect your logic in your code using EKSource array in EKEventStore

 EKEventStore *store = [[EKEventStore alloc] init]; for (EKSource *source in store.sources) if (source.sourceType == EKSourceTypeExchange || source.sourceType == EKSourceTypeCalDAV) { //Your custom logic here to determine if the local cal should be hidden. break; } 

Here you can find the full list of EKSourceType constants: http://developer.apple.com/library/ios/#documentation/EventKit/Reference/EKSourceClassRef/Reference/Reference.html

+5
source

All Articles