remove cachedResponseForRequest method

This commit is contained in:
Pan, Xinlei (Ryan) 2018-04-11 12:31:23 -04:00
parent 80d379609f
commit b319de5d16

View File

@ -535,11 +535,6 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
NSURLSession *session = [NSURLSession sessionWithConfiguration:configure]; NSURLSession *session = [NSURLSession sessionWithConfiguration:configure];
NSURLRequest *request = [NSURLRequest requestWithURL:s7URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:1800]; NSURLRequest *request = [NSURLRequest requestWithURL:s7URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:1800];
NSCachedURLResponse *response = [sharedCache cachedResponseForRequest:request]; NSCachedURLResponse *response = [sharedCache cachedResponseForRequest:request];
if (response != nil) {
UIImage *image = [UIImage imageWithData:response.data scale:[UIScreen mainScreen].scale];
completionHandler(image, nil, isFallBackImage);
return;
} else {
NSURLSessionDownloadTask *downloadImageTask = [session downloadTaskWithRequest:request completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) { NSURLSessionDownloadTask *downloadImageTask = [session downloadTaskWithRequest:request completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSData *data = [NSData dataWithContentsOfURL:location]; NSData *data = [NSData dataWithContentsOfURL:location];
NSCachedURLResponse *cachedreponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data]; NSCachedURLResponse *cachedreponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data];
@ -550,7 +545,6 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
}]; }];
[downloadImageTask resume]; [downloadImageTask resume];
return; return;
}
/* /*
// Check in memory cache // Check in memory cache
img = [self getCachedImageWithName:s7URL.absoluteString]; img = [self getCachedImageWithName:s7URL.absoluteString];