Pergunta

I'm trying to create a calendar that shows up in Apple's calendar (From my application), but I want it to be read only (only editable from my application, not two way sync to Apple's calendar system) -- I'd hoped using EKSourceTypeSubscribed would work for this, and used this code:

    EKSource *theSource = nil;
    for (EKSource *source in store.sources) {
        if (source.sourceType == EKSourceTypeSubscribed) {
            theSource = source;
            break;
        }
    }

To try and retrieve the related EKSource (as there doesn't seem to be a way to create new sources. However, unless the user already has some calendar they are subscribed to, it seems that this source type doesn't exist.

Any ideas?

Foi útil?

Solução

There is no notion of an EventKit calendar whose events you can modify, but that can't be modified from the native calendar app (or from any 3rd party calendar mgmt app, for that matter).

FYI calendars created with EKSourceTypeSubscribed are not read only, even if you could reliably find the source type.

EKCalendar *theCal = [EKCalendar calendarForEntityType:EKEntityTypeEvent eventStore:self.eventStore];
theCal.source = theSource; // per your source selection snippet above
NSLog(@"isImmutable %d, allowsContentModifications %d", [theCal isImmutable], [theCal allowsContentModifications]);

Results in

isImmutable 0, allowsContentModifications 1
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top