gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 17:07:31 24 4
gpt4 key购买 nike

当我在完成 block 中调用 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];
});
}];

最佳答案

来自documentation :

When the user taps to grant or deny access, the completion handler will be called on an arbitrary queue.

此外,所有与 UI 相关的事情必须在主队列中完成。这就是您需要 dispatch_async 的方式。

关于ios - 为什么在 requestAccessToEntity :completion? 中使用 performSegueWithIdentifier 时使用 dispatch_async,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22315313/

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