Determines at runtime is UIApplication is available as per #1082
This commit is contained in:
parent
f2252b3499
commit
17a4803661
|
@ -474,6 +474,10 @@ BOOL ImageDataHasPNGPreffix(NSData *data) {
|
|||
}
|
||||
|
||||
- (void)backgroundCleanDisk {
|
||||
Class UIApplicationClass = NSClassFromString(@"UIApplication");
|
||||
if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) {
|
||||
return;
|
||||
}
|
||||
UIApplication *application = [UIApplication sharedApplication];
|
||||
__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
|
||||
// Clean up any unfinished task business by marking where you
|
||||
|
|
|
@ -70,7 +70,9 @@
|
|||
}
|
||||
|
||||
#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
|
||||
if ([self shouldContinueWhenAppEntersBackground]) {
|
||||
Class UIApplicationClass = NSClassFromString(@"UIApplication");
|
||||
BOOL hasApplication = UIApplicationClass && [UIApplicationClass respondsToSelector:@selector(sharedApplication)];
|
||||
if (hasApplication && [self shouldContinueWhenAppEntersBackground]) {
|
||||
__weak __typeof__ (self) wself = self;
|
||||
self.backgroundTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
|
||||
__strong __typeof (wself) sself = wself;
|
||||
|
@ -122,6 +124,10 @@
|
|||
}
|
||||
|
||||
#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
|
||||
Class UIApplicationClass = NSClassFromString(@"UIApplication");
|
||||
if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) {
|
||||
return;
|
||||
}
|
||||
if (self.backgroundTaskId != UIBackgroundTaskInvalid) {
|
||||
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskId];
|
||||
self.backgroundTaskId = UIBackgroundTaskInvalid;
|
||||
|
|
Loading…
Reference in New Issue