Created
August 23, 2010 18:58
-
-
Save lukeredpath/546082 to your computer and use it in GitHub Desktop.
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
| From 3d40a3907187800559626589aab0b3263e3777ad Mon Sep 17 00:00:00 2001 | |
| From: Luke Redpath <luke@lukeredpath.co.uk> | |
| Date: Mon, 23 Aug 2010 19:57:36 +0100 | |
| Subject: [PATCH] Runtime checks are required for multi-tasking on iOS3 devices | |
| --- | |
| Classes/ASIHTTPRequest/ASIHTTPRequest.m | 13 +++++++++++-- | |
| 1 files changed, 11 insertions(+), 2 deletions(-) | |
| diff --git a/Classes/ASIHTTPRequest/ASIHTTPRequest.m b/Classes/ASIHTTPRequest/ASIHTTPRequest.m | |
| index 90c5974..9a05801 100644 | |
| --- a/Classes/ASIHTTPRequest/ASIHTTPRequest.m | |
| +++ b/Classes/ASIHTTPRequest/ASIHTTPRequest.m | |
| @@ -637,6 +637,15 @@ static NSOperationQueue *sharedQueue = nil; | |
| #pragma mark request logic | |
| +BOOL isMultitaskingSupported() | |
| +{ | |
| + BOOL multiTaskingSupported = NO; | |
| + if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) { | |
| + multiTaskingSupported = [[UIDevice currentDevice] isMultitaskingSupported]; | |
| + } | |
| + return multiTaskingSupported; | |
| +} | |
| + | |
| // Create the request | |
| - (void)main | |
| { | |
| @@ -645,7 +654,7 @@ static NSOperationQueue *sharedQueue = nil; | |
| [[self cancelledLock] lock]; | |
| #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 | |
| - if ([[UIDevice currentDevice] isMultitaskingSupported] && [self shouldContinueWhenAppEntersBackground]) { | |
| + if (isMultitaskingSupported() && [self shouldContinueWhenAppEntersBackground]) { | |
| backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ | |
| // Synchronize the cleanup call on the main thread in case | |
| // the task actually finishes at around the same time. | |
| @@ -2922,7 +2931,7 @@ static NSOperationQueue *sharedQueue = nil; | |
| CFRunLoopStop(CFRunLoopGetCurrent()); | |
| #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 | |
| - if ([[UIDevice currentDevice] isMultitaskingSupported] && [self shouldContinueWhenAppEntersBackground]) { | |
| + if (isMultitaskingSupported() && [self shouldContinueWhenAppEntersBackground]) { | |
| dispatch_async(dispatch_get_main_queue(), ^{ | |
| if (backgroundTask != UIBackgroundTaskInvalid) { | |
| [[UIApplication sharedApplication] endBackgroundTask:backgroundTask]; | |
| -- | |
| 1.7.0.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment