簡體   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