@@ -176,8 +176,13 @@ public class ImagePrefetcher {
/**
Stop current downloading progress, and cancel any future prefetching activity that might be occuring.
*/
- public func cancel() {
+ public func stop() {
dispatch_async_safely_to_main_queue {
+
+ if self.finished {
+ return
+ }
self.cancelled = true
self.tasks.forEach { (_, task) -> () in
task.cancel()
@@ -109,7 +109,7 @@ class ImagePrefetcherTests: XCTestCase {
prefetcher.maxConcurrentDownloads = maxConcurrentCount
prefetcher.start()
- prefetcher.cancel()
+ prefetcher.stop()
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {