Hi All can any one help me out how to clear the cache in AFNetworking.
I used to have old version of AFNetworking and i see that it has been updated, Can any body help m
If you are using AFNetworking3.0 through cocoapods, then use below code by creating category for UIImageView.
#import
#import
#import
+ (void)clearImageCacheForURL:(NSURL *)url {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
id imageCache = [[self class] sharedImageDownloader].imageCache;
UIImage *cachedImage = [imageCache imageforRequest:request withAdditionalIdentifier:nil];
if (cachedImage) {
[self clearCached:imageCache Request:request];
}
}
+ (void)clearCached:(AFAutoPurgingImageCache *)imageCache Request:(NSURLRequest *)request {
if (request) {
[imageCache removeImageforRequest:request withAdditionalIdentifier:nil];
}
}