#725 adding completition block when removing image from cache, added an extra method so we don't break compatibility with older versions
This commit is contained in:
parent
7edeef9f1a
commit
2ca5eab0e5
|
@ -127,6 +127,15 @@ typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType ca
|
|||
*/
|
||||
- (void)removeImageForKey:(NSString *)key;
|
||||
|
||||
|
||||
/**
|
||||
* Remove the image from memory and disk cache synchronously
|
||||
*
|
||||
* @param key The unique image cache key
|
||||
* @param completionBlock An block that should be executed after the image has been removed (optional)
|
||||
*/
|
||||
- (void)removeImageForKey:(NSString *)key withCompletition:(void (^)())completion;
|
||||
|
||||
/**
|
||||
* Remove the image from memory and optionally disk cache synchronously
|
||||
*
|
||||
|
@ -135,6 +144,15 @@ typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType ca
|
|||
*/
|
||||
- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk;
|
||||
|
||||
/**
|
||||
* Remove the image from memory and optionally disk cache synchronously
|
||||
*
|
||||
* @param key The unique image cache key
|
||||
* @param fromDisk Also remove cache entry from disk if YES
|
||||
* @param completionBlock An block that should be executed after the image has been removed (optional)
|
||||
*/
|
||||
- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletition:(void (^)())completion;
|
||||
|
||||
/**
|
||||
* Clear all memory cached images
|
||||
*/
|
||||
|
|
|
@ -303,21 +303,39 @@ BOOL ImageDataHasPNGPreffix(NSData *data) {
|
|||
}
|
||||
|
||||
- (void)removeImageForKey:(NSString *)key {
|
||||
[self removeImageForKey:key fromDisk:YES];
|
||||
[self removeImageForKey:key withCompletition:nil];
|
||||
}
|
||||
|
||||
- (void)removeImageForKey:(NSString *)key withCompletition:(void (^)())completion {
|
||||
[self removeImageForKey:key fromDisk:YES withCompletition:completion];
|
||||
}
|
||||
|
||||
- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk {
|
||||
[self removeImageForKey:key fromDisk:fromDisk withCompletition:nil];
|
||||
}
|
||||
|
||||
- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletition:(void (^)())completion {
|
||||
|
||||
if (key == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
[self.memCache removeObjectForKey:key];
|
||||
|
||||
|
||||
if (fromDisk) {
|
||||
dispatch_async(self.ioQueue, ^{
|
||||
[_fileManager removeItemAtPath:[self defaultCachePathForKey:key] error:nil];
|
||||
|
||||
if (completion) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
completion();
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (completion){
|
||||
completion();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)setMaxMemoryCost:(NSUInteger)maxMemoryCost {
|
||||
|
|
Loading…
Reference in New Issue