首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EKEventStore导致SpringBoard崩溃

EKEventStore导致SpringBoard崩溃
EN

Stack Overflow用户
提问于 2014-04-14 18:01:25
回答 1查看 567关注 0票数 0

我构建了一个应用程序,可以从日历(由EKEventStore predicateForEventsWithStartDate:endDate:calendars:)获取ekevents,并将应用程序事件与日历同步(使用EKEventStore saveEvent:span:commit:error:)。

我使用对EKEventStore的静态引用,并确保不同的进程不会同时访问EKEventStore

该应用程序有时会因IOS7上的Springboard崩溃而终止。这是崩溃的回溯。

代码语言:javascript
复制
Last Exception Backtrace:
0   CoreFoundation                  0x18625e950 __exceptionPreprocess + 132
1   libobjc.A.dylib                 0x1927641fc objc_exception_throw + 60
2   CoreFoundation                  0x18625e810 +[NSException raise:format:arguments:] +     116
3   Foundation                      0x186d96db4 -[NSAssertionHandler     handleFailureInMethod:object:file:lineNumber:description:] + 112
4   EventKit                        0x186adab84 -[EKEventStore _addFetchedObjectWithID:] + 240
5   EventKit                        0x186adaa64 __78-[EKEventStore registerFetchedObjectWithID:withDefaultLoadedProperties:inSet:]_block_invoke + 96
6   libdispatch.dylib               0x192d3bfd4 _dispatch_client_callout + 16
7   libdispatch.dylib               0x192d41c84 _dispatch_barrier_sync_f_invoke + 48
8   EventKit                        0x186ada990 -[EKEventStore     registerFetchedObjectWithID:withDefaultLoadedProperties:inSet:] + 148
9   EventKit                        0x186ae1458 __41-[EKPredicateSearch startWithCompletion:]_block_invoke + 796
10  EventKit                        0x186ae1050 -[EKDaemonConnection _processReplyWithID:data:finished:] + 220
11  EventKit                        0x186ae0f5c CADReceiveReply + 136
12  EventKit                        0x186ae0eac _XReply + 124
13  EventKit                        0x186ae0e04 ClientCallbacks_server + 100
14  libdispatch.dylib               0x192d3fae8 dispatch_mig_server + 352
15  EventKit                        0x186ae0d6c __43-[EKDaemonConnection initWithOptions:path:]_block_invoke16 + 44
16  libdispatch.dylib               0x192d3bfd4 _dispatch_client_callout + 16
17  libdispatch.dylib               0x192d3db90 _dispatch_source_invoke + 500
18  libdispatch.dylib               0x192d430f4 _dispatch_root_queue_drain + 104
19  libdispatch.dylib               0x192d434fc _dispatch_worker_thread2 + 76
20  libsystem_pthread.dylib         0x192ed16bc _pthread_wqthread + 356
21  libsystem_pthread.dylib         0x192ed154c start_wqthread + 4

以下是初始化我的ekeventstore的代码:

代码语言:javascript
复制
+ (EKEventStore *) sharedStore {
     static EKEventStore *sharedEventStore;

    if (sharedEventStore == nil) {
        sharedEventStore = [[EKEventStore alloc] init];
        [sharedEventStore requestAccessToEntityType: EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        }];
        [sharedEventStore reset];
    }

    return sharedEventStore;
}

获取事件的代码:

代码语言:javascript
复制
NSPredicate *predicate = [[CalendarHelper sharedStore] predicateForEventsWithStartDate:startDate
                                                        endDate:endDate
                                                      calendars:[[showableCalendars copy] autorelease]];
NSArray *result = [[CalendarHelper sharedStore] eventsMatchingPredicate:predicate];

以及更新/创建事件:

代码语言:javascript
复制
EKEvent *event = [[CalendarHelper sharedStore] eventWithIdentifier:eventId];
if(event != nil) {
    event.title = title;
    event.startDate = startDate;
    event.endDate = endDate;
    NSLog(@"Updating...");
    NSLog(@"+++ %@", event.eventIdentifier);

    [[CalendarHelper sharedStore] saveEvent:event span:EKSpanThisEvent commit:commit error:nil];
    NSLog(@"Updated.");
}
else {
    NSLog(@"No event, no update");
}

有什么线索吗?

EN

回答 1

Stack Overflow用户

发布于 2014-04-15 15:06:48

请检查您的ios版本。我在使用iOS 7.0.2时遇到了类似的崩溃,如果不是试试下面的代码

这个bug的原因似乎与我们试图在我们的应用程序中获取多少事件有关。查看苹果的错误报告(15424747)。

这个bug似乎是在我们的应用程序在eventStore上使用大范围的日期时引入的。

代码如下:

代码语言:javascript
复制
NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate     endDate:endDate calendars:nil]; 

//我们使用NSSortDescriptor进行排序

代码语言:javascript
复制
if (!self.masterListSortDescriptor)
{    
    self.masterListSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"startDate"  ascending:YES]; 
}

NSArray *result = [[self.eventStore eventsMatchingPredicate:predicate]
sortedArrayUsingDescriptors:@[self.masterListSortDescriptor]];
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23057212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档