Created
April 23, 2015 07:09
-
-
Save Superbil/3d8f81c45ee021190138 to your computer and use it in GitHub Desktop.
iOS start background.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)applicationDidEnterBackground:(UIApplication *)application | |
{ | |
UIApplication* app = [UIApplication sharedApplication]; | |
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{ | |
[app endBackgroundTask:bgTask]; | |
bgTask = UIBackgroundTaskInvalid; | |
}]; | |
// Start the long-running task and return immediately. | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, NULL), ^{ | |
// Do the work associated with the task. | |
[app endBackgroundTask:bgTask]; | |
bgTask = UIBackgroundTaskInvalid; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment