Reputation: 1323
I get events from a web service in my application, every event has an unique identifier.
If the user wants to push that event to native calender I will save that event in native but how would I know if that event is already existing in the native Calendar as I can't set eventIdentifier property of EKEvent object
I tried subclassing EKEvent and adding my own identifier
eventStore = [[EKEventStore alloc] init];
MyEvent *event = [MyEvent eventWithEventStore:eventStore];
event.myEventIdentifier = @"MyEventIdentifier";
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
event.startDate = [NSDate date];
event.endDate = [NSDate dateWithTimeIntervalSinceNow:10000];
event.title = @"MyEventTitle";
[eventStore saveEvent:event span:EKSpanThisEvent error:nil];
But when I retrive event object I dont get my subclass object and it was throwing an exception when I called
[event valueForKey:@"MyEventIdentifier"];
Now as you can see, I can't set eventIdentifier property in EKEvent class, also subclassing EKEvent doesn't work.
How can I achieve the required functionality, any suggestions?
Upvotes: 3
Views: 1754
Reputation: 495
Im looking into EKEvent for something similar, but EKEvent does has an identifier of which you can access.
Once you save the event, you can access its identifier,
NSString *eventID = [NSString stringWithFormat:@"%@", event.eventIdentifier];
Save this string and use it to remove the events, but note event.eventIdentifier is READ only,
Upvotes: 3