Search code examples
iosobjective-ceventkitekeventkit

How can I create EKEventStore different instances with different Identifiers?


I want to create three instances of EKEventStore class to store my 3 different events,

EKEventStore *event = [EKEventStore alloc] init];
EKEventStore *event1 = [EKEventStore alloc] init];
EKEventStore *event2 = [EKEventStore alloc] init];

When I checked their eventStoreIdentifier like

NSString *idStr = [event eventStoreIdentifier];

They are actually show same ID and I am unable to separate them.

I have not much worked with Events So anyone can guide me

Thanks.


Solution

  • The EKEventStore is the point of access for calendar and reminder data. You have discovered they all point to the same data. This is because there is only one set of data available to iOS at any time.

    To store events requires creating EKEvents and associating them to the event store.

    For example:

    EKEventStore *theEventStore = [EKEventStore alloc] init];
    EKEvent *event = [EKEvent eventWithEventStore:theEventStore];
    
    // Set event properties here.
    
    NSError *error;
    [eventStore saveEvent:event span:EKSpanThisEvent error:&error];