gpt4 book ai didi

ios - 无法结束 BackgroundTask : no background task exists with identifier 1fd57580, 或者它可能已经结束

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:25:32 25 4
gpt4 key购买 nike

AppDelegate.m 文件包含

- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIBackgroundTaskIdentifier taskID = [application beginBackgroundTaskWithExpirationHandler:^{
[application endBackgroundTask:taskID];
}];
}

我不知道为什么我在 gdb 中收到这条消息

Can't endBackgroundTask: no background task exists with identifier 1fd57580, or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

最佳答案

你的代码全错了。它应该是这样的:

UIBackgroundTaskIdentifier taskID = [application beginBackgroundTaskWithExpirationHandler:^{
// Code to ensure your background processing stops executing
// so it reaches the call to endBackgroundTask:
}];

// Put the code you want executed in the background here

if (taskID != UIBackgroundTaskInvalid) {
[[UIApplication sharedApplication] endBackgroundTask:taskID];
}

关于ios - 无法结束 BackgroundTask : no background task exists with identifier 1fd57580, 或者它可能已经结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33295384/

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