1

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?

Mind Pixel
  • 816
  • 7
  • 16
BadPirate
  • 25,802
  • 10
  • 92
  • 123
  • You can put up an rss feed through a UIWebserver instance and then just run it. (it does not need to be server side). – Paulo May 12 '14 at 19:22
  • UIWebserver isn't a real thing (Though there are open source frameworks for doing lightweight web services from an iOS app) :) However you can't run in the background very long, so whenever iOS tries to refresh your calendar it is likely to fail (as the app will be suspended)... Though it might be an okay way to get the calendar created in the first place (pretty sure calling a faked iCal feed would cause a flip though)... – BadPirate May 12 '14 at 21:33

1 Answers1

0

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
mygzi
  • 1,303
  • 1
  • 11
  • 21
  • It does seem that method won't work, subscribed source will still create calendars that are user editable (unless iOS creates them from a feed, and then the flag to prevent user editing is in the EKCalendar)... Any way to configure that? (Original question) – BadPirate May 09 '14 at 21:15
  • As you can observe in the [class reference](https://developer.apple.com/library/ios/documentation/DataManagement/Reference/EKCalendarClassRef/Reference/Reference.html#//apple_ref/doc/uid/TP40009564-CH1-DontLinkElementID_4), all of the interesting EKCalendar properties are `readonly`. Might be out of scope, but you could actually build a server side feed and have your users subscribe to it... – mygzi May 10 '14 at 04:25
  • While I'd love to find an answer to this one... it appears as if this is just a half assed Apple API :) Seems to me that if you have to use an EKSource to create a calendar, they should let you create the source as needed. Oh well. I'll file an apple bug / request. – BadPirate May 12 '14 at 17:39
  • Indeed. Best of luck. – mygzi May 12 '14 at 23:28