Przeglądaj źródła

Only use the runloop with timeout on iOS 5 (fix #497)

Olivier Poitrey 12 lat temu
rodzic
commit
03d28fee03
1 zmienionych plików z 12 dodań i 4 usunięć
  1. 12 4
      SDWebImage/SDWebImageDownloaderOperation.m

+ 12 - 4
SDWebImage/SDWebImageDownloaderOperation.m

@@ -70,10 +70,18 @@
         }
         [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self];
 
-        // Make sure to run the runloop in our background thread so it can process downloaded data
-        // Note: we use a timeout to work around an issue with NSURLConnection cancel under iOS 5
-        //       not waking up the runloop, leading to dead threads (see https://github.com/rs/SDWebImage/issues/466)
-        CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, false);
+        if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_5_1)
+        {
+            // Make sure to run the runloop in our background thread so it can process downloaded data
+            // Note: we use a timeout to work around an issue with NSURLConnection cancel under iOS 5
+            //       not waking up the runloop, leading to dead threads (see https://github.com/rs/SDWebImage/issues/466)
+            CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, false);
+        }
+        else
+        {
+            CFRunLoopRun();
+        }
+
         if (!self.isFinished)
         {
             [self.connection cancel];