Luke Redpath
Committed by Ben Copsey

Runtime checks are required for multi-tasking on iOS3 devices

@@ -665,6 +665,15 @@ static NSOperationQueue *sharedQueue = nil; @@ -665,6 +665,15 @@ static NSOperationQueue *sharedQueue = nil;
665 665
666 #pragma mark request logic 666 #pragma mark request logic
667 667
  668 +BOOL isMultitaskingSupported()
  669 +{
  670 + BOOL multiTaskingSupported = NO;
  671 + if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) {
  672 + multiTaskingSupported = [[UIDevice currentDevice] isMultitaskingSupported];
  673 + }
  674 + return multiTaskingSupported;
  675 +}
  676 +
668 // Create the request 677 // Create the request
669 - (void)main 678 - (void)main
670 { 679 {
@@ -673,7 +682,7 @@ static NSOperationQueue *sharedQueue = nil; @@ -673,7 +682,7 @@ static NSOperationQueue *sharedQueue = nil;
673 [[self cancelledLock] lock]; 682 [[self cancelledLock] lock];
674 683
675 #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 684 #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
676 - if ([[UIDevice currentDevice] isMultitaskingSupported] && [self shouldContinueWhenAppEntersBackground]) { 685 + if (isMultitaskingSupported() && [self shouldContinueWhenAppEntersBackground]) {
677 backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ 686 backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
678 // Synchronize the cleanup call on the main thread in case 687 // Synchronize the cleanup call on the main thread in case
679 // the task actually finishes at around the same time. 688 // the task actually finishes at around the same time.
@@ -2966,7 +2975,7 @@ static NSOperationQueue *sharedQueue = nil; @@ -2966,7 +2975,7 @@ static NSOperationQueue *sharedQueue = nil;
2966 CFRunLoopStop(CFRunLoopGetCurrent()); 2975 CFRunLoopStop(CFRunLoopGetCurrent());
2967 2976
2968 #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 2977 #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
2969 - if ([[UIDevice currentDevice] isMultitaskingSupported] && [self shouldContinueWhenAppEntersBackground]) { 2978 + if (isMultitaskingSupported() && [self shouldContinueWhenAppEntersBackground]) {
2970 dispatch_async(dispatch_get_main_queue(), ^{ 2979 dispatch_async(dispatch_get_main_queue(), ^{
2971 if (backgroundTask != UIBackgroundTaskInvalid) { 2980 if (backgroundTask != UIBackgroundTaskInvalid) {
2972 [[UIApplication sharedApplication] endBackgroundTask:backgroundTask]; 2981 [[UIApplication sharedApplication] endBackgroundTask:backgroundTask];