gpt4 book ai didi

objective-c - 在后台执行任务

转载 作者:行者123 更新时间:2023-11-28 20:34:28 26 4
gpt4 key购买 nike

在我的应用程序中,用户按下开始按钮后,我在 for 循环中执行一些代码。在此期间如何让应用程序对用户交互负责?C#中有BackgroundWorker类,IOS中有类似的吗?

最佳答案

像下面这样使用gcd

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^ {
//Put your heavy code here it will not block the user interface
});

关于objective-c - 在后台执行任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11074280/

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