gpt4 book ai didi

ios - 即使 backgroundTimeRemaining 为零,代码仍在后台运行?

转载 作者:可可西里 更新时间:2023-11-01 04:02:11 27 4
gpt4 key购买 nike

        UIApplication *application = [UIApplication sharedApplication];

UIBackgroundTaskIdentifier background_task = 0;

background_task = [application beginBackgroundTaskWithExpirationHandler: ^{

[application endBackgroundTask:background_task];
}];

SEL selector = NSSelectorFromString(action);
timer = [NSTimer scheduledTimerWithTimeInterval:floatUpdateInterval target:self selector:selector userInfo:nil repeats:YES];

即使在 backgroundTimeRemaining 为 0(零)后,上述代码(计时器)仍在运行。这怎么可能?上述类型的方法不是最多 10 分钟吗?

上面的代码是否被认为是可以安全提交的“应用程序商店”?

最佳答案

您正在创建一个计划重复的计时器。 beginBackgroundTaskWithExpirationHandler 将在时间到时被调用,这是您停止任何未及时完成的​​事情的机会。

您应该使 beginBackgroundTaskWithExpirationHandler 中的计时器无效。

关于ios - 即使 backgroundTimeRemaining 为零,代码仍在后台运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22002703/

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