Add id to events in Objective-C reminder

I add reminder events using Eventkit.framework in my application, but when I show reminder events in my application, it shows all reminder events on iPhone, but I want to show reminder events that I added.

Here is my code for adding an event using a modal view controller

 EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil]; EKEvent * eve = [EKEvent eventWithEventStore:self.eventStore]; addController.eventStore = self.eventStore; addController.event = eve; [self presentModalViewController:addController animated:YES]; 

here is the code to retrieve reminder events

 self.eventStore = [[EKEventStore alloc] init]; self.eventsList = [[NSMutableArray alloc] initWithArray:0]; self.defaultCalendar = [self.eventStore defaultCalendarForNewEvents]; self.navigationController.delegate = self; [self.eventsList addObjectsFromArray:[self fetchEventsForToday]]; 

event method selection

 - (NSArray *)fetchEventsForToday { NSDate *startDate = [NSDate date]; NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:86400]; NSArray *calendarArray = [NSArray arrayWithObject:defaultCalendar]; NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:calendarArray]; NSArray *events = [self.eventStore eventsMatchingPredicate:predicate]; return events; } 
+4
source share
1 answer

Each event has an eventIdentifier property, a unique identification string for each event. When your application adds events, it can store eventIdentifiers in its application data, and then load this list every time it starts. You can verify that the events were not deleted by making sure [self.eventStore eventWithIdentifier:identifier]; returns a valid EKEvent. When you want to display a list of events added to the application, you can simply get events that match the identifiers you saved. Since identifiers will never be reused, this system will not be dependent on users who add and remove events outside of your application.

+3
source

Source: https://habr.com/ru/post/1482955/


All Articles