Part of my app requires calendar access, which requires a call to the EKEventStore
method -(void)requestAccessToEntityType:(EKEntityType)entityType comple
[alertView show]
is not thread safe, so it is adding its UI change to the queue from which the completion block was dispatched rather than the main queue. I resolved this issue by adding dispatch_async(dispatch_get_main_queue(), ^{});
around the code inside the completion block:
[eventStore requestAccessToEntityType:EKEntityTypeEvent
completion:^(BOOL granted, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (granted) {
[self createCalendarEvent];
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Calendar Access Denied"
message:@"Please enable access in Privacy Settings to use this feature."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
});
}];