in my code I am retrieving the users reminders and displaying them a tableview. Whenever I print NSLog in my code, the the tables array gets displayed properly. But whenever I leave out NSLog in my code, my data isn't displayed properly anymore. The value for "title" of the reminder returns (null).
I can reproduce the issue every time. Anyone have any idea what is happening here?
- (void)shareReminderButtonAction:(UIButton *)buttonEvent {
EKEventStore *store = [[EKEventStore alloc] init];
NSPredicate *predicate = [store predicateForRemindersInCalendars:nil];
[store requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
[store fetchRemindersMatchingPredicate:predicate completion:^(NSArray *reminders) {
ReminderView *shareRem = [[ReminderView alloc]init];
NSLog(@"Reminders: %@", reminders);
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:shareRem];
[navigation setNavigationBarHidden:YES];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:navigation animated:YES
completion:^(void){[shareRem setArray:reminders];}];
}];
}];
}
Log data with NSLog in my code above:
"EKReminder <0x1d5b3630> {title = Gdghv; dueDate = 2013-03-06 22:00:00 +0000; completionDate = (null); priority = 0; calendarItemIdentifier = 0BD2CB76-588B-4103-86B0-D71D22317DC0}"
Log data at the UITableViewController end when receiving data without the NSLog in my code above:
CADObjectGetInlineStringProperty failed fetching title for EKPersistentReminder with error Error Domain=NSMachErrorDomain Code=268435459 "The operation couldn\342\200\231t be completed. (Mach error 268435459 - (ipc/send) invalid destination port)"
"EKReminder <0x1c5e6fd0> {title = (null); dueDate = (null); completionDate = (null); priority = 0; calendarItemIdentifier = (null)}"
Thanks alot!
The EKEventStore object needs to be kept around for the entire time you are using Event Kit objects. It's normally best to house it within a singleton. From Apple's docs :
An EKEventStore object requires a relatively large amount of time to initialize and release. Consequently, you should not initialize and release a separate event store for each event-related task. Instead, initialize a single event store when your app loads, and use it repeatedly to ensure that your connection is long-lived.
An event store instance must not be released before other Event Kit objects; otherwise, undefined behavior may occur.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.