gpt4 book ai didi

iphone - 请求访问日历时,iOS 6应用程序崩溃

转载 作者:行者123 更新时间:2023-12-03 17:39:52 25 4
gpt4 key购买 nike

它在以下行崩溃:

eventStoreQueue = dispatch_queue_create("com.example.nativecalexample", NULL);

//代码
- (id)init
{
if ((self = [super init])) {
eventStore = [[EKEventStore alloc] init];
if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])
{
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error)
{
events = [[NSMutableArray alloc] init];
items = [[NSMutableArray alloc] init];
eventStoreQueue = dispatch_queue_create("com.example.nativecalexample", NULL);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(eventStoreChanged:) name:EKEventStoreChangedNotification object:nil];
}];
}
}

return self;
}

- (void)presentingDatesFrom:(NSDate *)fromDate to:(NSDate *)toDate delegate:(id<KalDataSourceCallbacks>)delegate
{
// asynchronous callback on the main thread
[events removeAllObjects];
//NSLog(@"Fetching events from EventKit between %@ and %@ on a GCD-managed background thread...", fromDate, toDate);
dispatch_async(eventStoreQueue, ^{
NSDate *fetchProfilerStart = [NSDate date];
NSPredicate *predicate = [eventStore predicateForEventsWithStartDate:fromDate endDate:toDate calendars:nil];
NSArray *matchedEvents = [eventStore eventsMatchingPredicate:predicate];
dispatch_async(dispatch_get_main_queue(), ^{
//NSLog(@"Fetched %d events in %f seconds", [matchedEvents count], -1.f * [fetchProfilerStart timeIntervalSinceNow]);
[events addObjectsFromArray:matchedEvents];
[delegate loadedDataSource:self];
});
});
}

编辑:当应用程序崩溃时,我在那一行得到EXC_BAD_ACCESS,屏幕截图: http://i45.tinypic.com/2kzeu.png

最佳答案

检查eventStoreQueue是否有效创建:

eventStoreQueue = dispatch_queue_create("com.example.nativecalexample", NULL);
NSLog(@"Created eventStoreQueue: %x", eventStoreQueue);

如果是的话,还请确保在输入 presentingDatesFrom之前不释放它。

关于iphone - 请求访问日历时,iOS 6应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13413548/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com