diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m index de4a78e..bb97f89 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m @@ -533,10 +533,13 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; //call nsurlsession again, if image is cached by Freebee, the second session will grab image data from cache instead of making another server call NSURLSessionDownloadTask *downloadImageTask = [session downloadTaskWithRequest:request completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) { NSData *data = [NSData dataWithContentsOfURL:location]; - NSCachedURLResponse *cachedReponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data]; - //system stores cache based datatask and check cache based on response, - //need to manually store cache for response - [sharedCache storeCachedResponse:cachedReponse forRequest:request]; + //check data and response first, since they are nullable + if (data && response) { + NSCachedURLResponse *cachedReponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data]; + //system stores cache based datatask and check cache based on response, + //need to manually store cache for response + [sharedCache storeCachedResponse:cachedReponse forRequest:request]; + } if (isGif) { [self checkImage:nil imageData:data fallbackImage:fallbackImageName completionHandler:completionHandler]; } else {