Skip to content

Instantly share code, notes, and snippets.

@kwojtaszek
Created July 16, 2012 18:32
Show Gist options
  • Save kwojtaszek/3124193 to your computer and use it in GitHub Desktop.
Save kwojtaszek/3124193 to your computer and use it in GitHub Desktop.
UIBackgroundTaskIdentifier bgTask;
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
bgTask = [[UIApplication sharedApplication]
beginBackgroundTaskWithExpirationHandler:
^{
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
}];
[self disconnect]
if (bgTask != UIBackgroundTaskInvalid) {
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment