__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
// Clean up any unfinished task business by marking where you
// stopped or ending the task outright.
[application endBackgroundTask:bgTask]; //这里调用endBackgroundTask:bgTask是什么意思??????后面队列block中又调用一次,这里是告诉系统后台任务完成?麻烦帮忙看一下,尽量解释清楚。 谢谢!
}];
// Start the long-running task and return immediately.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work associated with the task, preferably in chunks.
//UIBackgroundTaskInvalid
NSLog(@"Starting background task with %0.1f seconds remaining", application.backgroundTimeRemaining);
[NSThread sleepForTimeInterval:600];
NSLog(@"Finishing background task with %0.1f seconds remaining",application.backgroundTimeRemaining);
//告诉系统我们完成了
[application endBackgroundTask:bgTask]; //这里又是什么意思????
});
// Clean up any unfinished task business by marking where you
// stopped or ending the task outright.
[application endBackgroundTask:bgTask]; //这里调用endBackgroundTask:bgTask是什么意思??????后面队列block中又调用一次,这里是告诉系统后台任务完成?麻烦帮忙看一下,尽量解释清楚。 谢谢!
}];
// Start the long-running task and return immediately.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work associated with the task, preferably in chunks.
//UIBackgroundTaskInvalid
NSLog(@"Starting background task with %0.1f seconds remaining", application.backgroundTimeRemaining);
[NSThread sleepForTimeInterval:600];
NSLog(@"Finishing background task with %0.1f seconds remaining",application.backgroundTimeRemaining);
//告诉系统我们完成了
[application endBackgroundTask:bgTask]; //这里又是什么意思????
});