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/