问题
When I call the performSegueWithIdentifier in the completion block, if I do not wrap the call in a dispatch_async, it literally takes 10 seconds for the segue to actually happen. However, I can do other things without wrapping them in the same dispatch_async, such as doing core data work, or, logging "things"...
Any insight as to how this works and why... I am lost. If this isn't the right place to ask something like this, I apologize.
EKEventStore *store = [[EKEventStore alloc] init];
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier:self.phaseSegue sender:self];
});
}];
回答1:
From the documentation:
When the user taps to grant or deny access, the completion handler will be called on an arbitrary queue.
Also, all UI-related stuff must be done on the main queue. That's way you need that dispatch_async
.
来源:https://stackoverflow.com/questions/22315313/why-use-dispatch-async-when-using-performseguewithidentifier-in-requestaccesstoe