为什么在requestAccessToEntity中使用performSegueWithIdentifier时使用dispatch_async:completion?

cri*_*ald 3 cocoa objective-c ios uistoryboardsegue ekeventstore

当我在完成块中调用performSegueWithIdentifier时,如果我没有将调用包装在dispatch_async中,则实际发生segue需要10秒钟.但是,我可以做其他事情而不将它们包装在同一个dispatch_async中,例如进行核心数据工作,或者记录"事物"......

任何关于这如何工作的原因以及为什么......我迷失了.如果这不是问这样的事的正确的地方,我道歉.

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];
    });
}];
Run Code Online (Sandbox Code Playgroud)

Mar*_*bri 7

文档:

当用户点击以授予或拒绝访问时,将在任意队列上调用完成处理程序.

此外,所有与UI相关的东西必须在主队列上完成.这就是你需要的方式dispatch_async.