Created
November 20, 2012 23:32
-
-
Save naotokui/4122008 to your computer and use it in GitHub Desktop.
Background execution with UIBackgroundTaskIdentifier
This file contains 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
// バックグラウンド処理のスタートを宣言 | |
UIBackgroundTaskIdentifier bgTask = UIBackgroundTaskInvalid; | |
bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ | |
[[UIApplication sharedApplication] endBackgroundTask:bgTask]; | |
}]; | |
/* ここでやりたい処理をする */ | |
// バックグラウンド処理の終了 | |
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