diff --git a/SAMCache/SAMCache.m b/SAMCache/SAMCache.m index c007286..bcd7560 100644 --- a/SAMCache/SAMCache.m +++ b/SAMCache/SAMCache.m @@ -284,9 +284,10 @@ - (UIImage *)imageForKey:(NSString *)key { // Load object from disk image = [UIImage imageWithContentsOfFile:path]; - - // Store in cache - [self.cache setObject:image forKey:key]; + if (image) { + // Store in cache + [self.cache setObject:image forKey:key]; + } return image; }