简体   繁体   English

奇怪的数据解析问题

[英]Strange data parsing issue

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. 每当我在代码中打印NSLog时,表数组都会正确显示。 But whenever I leave out NSLog in my code, my data isn't displayed properly anymore. 但是,每当我在代码中忽略NSLog时,数据就无法正确显示。 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: 在上面的代码中使用NSLog记录数据:

"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: 在上面我的代码中接收没有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)}"

Thanks alot! 非常感谢!

The EKEventStore object needs to be kept around for the entire time you are using Event Kit objects. 在使用事件工具包对象的整个过程中,都必须保留EKEventStore对象。 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. EKEventStore对象需要相对大量的时间来初始化和释放。 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. 否则,可能会发生不确定的行为。

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

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