Skip to content

Commit

Permalink
- fixed a bug where the task was not cancelled and the downloaded ima…
Browse files Browse the repository at this point in the history
…ge in a list was set more then once.
  • Loading branch information
lucianboboc committed Sep 15, 2015
1 parent 0c94f3e commit 6f2eb04
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion LBCache.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "LBCache"
s.version = "1.0.5"
s.version = "1.0.6"
s.summary = "LBCache image cache framework"
s.description = <<-DESC
LBCache is an asynchronous image cache framework for iOS.
Expand Down
17 changes: 15 additions & 2 deletions LBCache/ImageOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @interface ImageOperation () <NSURLSessionDataDelegate, NSURLSessionTaskDelegate
@property (copy, nonatomic) ProgressBlock progressBlock;
@property (strong, nonatomic) NSURL *location;
@property (nonatomic) LBCacheImageOptions options;
@property (strong, nonatomic) NSURLSessionDownloadTask *task;

@property (assign, nonatomic, getter = isExecuting) BOOL executing;
@property (assign, nonatomic, getter = isFinished) BOOL finished;
Expand Down Expand Up @@ -68,10 +69,22 @@ - (void) done
}


- (void) cancel {
[super cancel];

[self cancelTask];
}

- (void) cancelTask {
[self.task cancel];
}


- (void) start
{
if(self.isCancelled)
{
[self cancelTask];
[self done];
return;
}
Expand Down Expand Up @@ -136,8 +149,8 @@ -(void) getImageFromTheServer {

[[NSNotificationCenter defaultCenter] postNotificationName:LBCacheDownloadImageStartedNotification object:self];

NSURLSessionDownloadTask *task = [self.sesstion downloadTaskWithRequest: request];
[task resume];
self.task = [self.sesstion downloadTaskWithRequest: request];
[self.task resume];
}

-(void) loadOnlyFromCache
Expand Down
8 changes: 0 additions & 8 deletions LBCache2-Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
children = (
25C65F44175D39F100AE8FFC /* AppDelegate.h */,
25C65F45175D39F100AE8FFC /* AppDelegate.m */,
67F123B61844ECF6008F01BD /* LBCache */,
25C65F4D175D39F100AE8FFC /* MainStoryboard.storyboard */,
25C65F50175D39F100AE8FFC /* ViewController.h */,
25C65F51175D39F100AE8FFC /* ViewController.m */,
Expand Down Expand Up @@ -257,13 +256,6 @@
name = "Supporting Files";
sourceTree = "<group>";
};
67F123B61844ECF6008F01BD /* LBCache */ = {
isa = PBXGroup;
children = (
);
path = LBCache;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down

0 comments on commit 6f2eb04

Please sign in to comment.