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 AFNetworking using cocoaPods then you can do this by making a category of UIImageView (clearCache)
- (void)clearImageCacheForURL:(NSURL *)url {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:request];
if (cachedImage) {
[self clearCached:[[self class] sharedImageCache] Request:request];
}
}
- (void)clearCached:(NSCache *)imageCache Request:(NSURLRequest *)request {
if (request) {
[imageCache removeObjectForKey:[[request URL] absoluteString]];
}
}