繁体   English   中英

奇怪的数据解析问题

[英]Strange data parsing issue

在我的代码中,我正在检索用户提醒并将其显示为表格视图。 每当我在代码中打印NSLog时,表数组都会正确显示。 但是,每当我在代码中忽略NSLog时,数据就无法正确显示。 提醒的“标题”值返回(空)。

我每次都可以重现该问题。 有人知道这里发生了什么吗?

- (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];}];

    }];

}];

}

在上面的代码中使用NSLog记录数据:

"EKReminder <0x1d5b3630> {title = Gdghv; dueDate = 2013-03-06 22:00:00 +0000; completionDate = (null); priority = 0; calendarItemIdentifier = 0BD2CB76-588B-4103-86B0-D71D22317DC0}"

在上面我的代码中接收没有NSLog的数据时,在UITableViewController端记录数据:

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)}"

非常感谢!

在使用事件工具包对象的整个过程中,都必须保留EKEventStore对象。 通常最好将其容纳在一个单例中。 苹果的文档

EKEventStore对象需要相对大量的时间来初始化和释放。 因此,您不应为每个与事件相关的任务初始化和释放单独的事件存储。 相反,应在应用程序加载时初始化单个事件存储,然后重复使用它以确保连接寿命长。

不能在其他事件工具包对象之前释放事件存储实例。 否则,可能会发生不确定的行为。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM