0

I am making an app for myself and I need to access the startDate and endDate of specific events that are already in my calendar. How can I go about doing this? I have tried storing a list of events into an array but once the events are in the array, what is the point, how can I access them?

4

1 回答 1

1

You can save the eventIdentifier property of the EKEvents in the array.

EKEventStore *eventStore = [[EKEventStore alloc] init];
// Create the predicate from the event store's instance method

NSPredicate *predicate = [store predicateForEventsWithStartDate:oneDayAgo

                                                    endDate:oneYearFromNow

                                                  calendars:nil];



// Fetch all events that match the predicate

NSArray *eventsArray = [store eventsMatchingPredicate:predicate];

for (EKEvent *eventToCheck in eventsArray) {
    if ([eventToCheck.eventIdentifier isEqualToString:[eventsIdentifierArray objectAtIndex:i]]) {
        //Do your changes here
        NSLog(@"%@", eventToCheck.startDate);
        NSLog(@"%@", eventToCheck.endDate);
    }
}

Refer this

于 2012-09-10T17:07:20.377 回答