Handle nil image urls nicely

This commit is contained in:
Olivier Poitrey 2009-12-31 14:12:50 +01:00
parent 0bdd448ca8
commit a230f6aba8
2 changed files with 12 additions and 2 deletions

View File

@ -126,7 +126,7 @@ static SDImageCache *instance;
- (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk
{
if (image == nil)
if (image == nil || key == nil)
{
return;
}
@ -146,6 +146,11 @@ static SDImageCache *instance;
- (UIImage *)imageFromKey:(NSString *)key fromDisk:(BOOL)fromDisk
{
if (key == nil)
{
return nil;
}
UIImage *image = [memCache objectForKey:key];
if (!image && fromDisk)
@ -163,6 +168,11 @@ static SDImageCache *instance;
- (void)removeImageForKey:(NSString *)key
{
if (key == nil)
{
return;
}
[memCache removeObjectForKey:key];
[[NSFileManager defaultManager] removeItemAtPath:[self cachePathForKey:key] error:nil];
}

View File

@ -53,7 +53,7 @@ static SDWebImageManager *instance;
- (void)downloadWithURL:(NSURL *)url delegate:(id<SDWebImageManagerDelegate>)delegate
{
if ([failedURLs containsObject:url])
if (url == nil || [failedURLs containsObject:url])
{
return;
}