Clearing cache of MHLazyTableImages - iphone

I want to clear cache used by MHLazyTableImages for images when i changed images from server. but i am unable to find where it is storing that images. So Will you please guide me.

for clearing your MHLazyTableImages cache write following code line...
[[MHImageCache sharedInstance] flushMemory];
OR
instead of MHLazyTableImages, you use EGOImageView from EGOImageLoading

Related

Flutter - Cache_network_image. I replaced old image with new image with same name. But it doesn't affect on app

I am new to flutter. I have used library of "cache_network_image" which help to show images from the internet and keep them in the cache directory. In first load, it download the images and stored in cache directory(cache manager) and displayed in app.
Example. I have an image(test.png), it downloaded from network and stored in cache successfully. But If I replace test.png image with new image with same name of test.png. So It should display new image
with that same name(test.png). It's displaying only old image.
The cache_network_image library not working properly. Please share your thoughts.
no, it doesn't care whats in the end of the url, all it cares is whether file exists locally, if it doesn't then only it'll fetch from the url, if you want to refetch the updated image you have clear the cache, delete the app data or if you want to clear programmatically
var cm = DefaultCacheManager();
cm.emptyCache();

How to save ALAssetsLibrary to usersDefault when i close my app?

When i save images in ALAssetsLibrary, it's ok to show them in my table, but when i close my app from multitasking bar - records is cleared. How to save them and stay load in my table when i run my app again???
I found this Saving ALAsset URL in NSUserDefaults
I think you want to save resources so that you can use them later. If it does, you can save the path of resource to your user defaults or core data, and store them into "Photo Album". When you need it, just use the path in string as the resource path to get it.
Take a look at ALAssetsLibrary+CustomPhotoAlbum, maybe you'll like it. ;)

SDWebImage clearing cache

I'm displaying a list of icons downloaded from the web with text in a table view. The icons can be changed on server side and I need to replace them as soon as new icons are getting available. I try using the following code:
[imgView setImageWithURL:url placeholderImage:[UIImage imageNamed:#"table_avatar_icon"] options:SDWebImageCacheMemoryOnly];
And call [[SDImageCache sharedImageCache] clearMemory]; In my refresh callback, but it does not purge the contents of the cache. More to it, even if I close the application and open it again the image is still there.
I found only one way to clear the cache and it is by calling [[SDImageCache sharedImageCache] clearDisk];. Which only works after I close and reopen the app.
How can I force SDWebImage to not to use disk caching?
SDImageCache *imageCache = [SDImageCache sharedImageCache];
[imageCache clearMemory];
[imageCache clearDisk];
Don't forget to put these lines of code in your didReceiveMemoryWarning, too.
Located the source if an issue. It seems that I was deceived by the Singleton pattern used in SDImageCache. The cache for extension that is used over UIImageView is being controlled by SDWebImageManager which has an instance variable of SDImageCache. If you want to clear the cache for extension you have to call its imageCache's methods like clearDisk and clearMemory.
Only following code worked for me : Swift 5.0, Xcode 11, iOS 13, SDWebImage pod 5.0
SDWebImageManager.shared.imageCache.clear(with: .all) {
print("deleted all")
}
where you choose options like SDImageCacheType.disk, SDImageCacheType.memory, SDImageCacheType.disk
Also if you want to remove specific image from cache use following:
SDWebImageManager.shared.imageCache.removeImage(forKey: "url of image", cacheType: .all)
Except SDImageCache methods, I strongly advise you to check your image urls. In my situation I tried every method for imageCache and memory issue was still continue. Crashes were occur mainly on iPhone 4s because of hardware it couldn't handle it.
Main issue was url ampersand encoding!
In example, check out these urls: first url is using "&amp" and second one is not. Because of ampersand my JSON library can't read the width and width value get much higher then it should be. That is why I had a memory issue.
1) /select.php?imageid=101961221 "&amp" ;width=100 "&amp" ;isWatermarked=true
2) /select.phpimageid=101961221&width=100&isWatermarked=true
Also the latest versions of SDWebImage library has include UIImageView+WebCache.h class and it really nicely handle cache problems.
The icons can be changed on server side,
so you need to load with refresh cached every time.
if you're using latest SDWebImage framework (5.12.x)
you can call it like this,
[imgView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:#"xxx" options:SDWebImageRefreshCached];
edit at 220112.

Downloading image from server without file extension (NSData to UIImage)

From my server I'm pulling down a url that is supposed to simply be a profile image. The relevant code for pulling down the image from the urls is this:
NSString *urlString = [NSString stringWithFormat:#"%#%#",kBaseURL,profile_image_url];
profilePic = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]]];
My url is in the format (note no file extension on the end since its dynamically rendered)
localhost:8000/people/1/profile_image
If I load the url in my browser the image displays; however the code above for pulling down the UIImage does not work. I've verified that the code does pull an image from a random site on the interwebs.
Any thoughts on why this is happening?
Does it work if you feed NSURL
http://localhost:8000/people/1/profile_image
I imagine that the http:// is important here (so that the NSURL knows whether it's pointing at a file or remote URL).
The reason you can't display it in a UIImageView is because the UIImageView doesn't know what format it's in (jpeg,png,etc.)
A good way for future coding is always use extensions. Don't take short cuts, they will always end up worse and you'll have to fix them over and over again.
First check for the following :
Permissions: change from read only to read and write.
I have tried many methods in my project to display pic from server and the most prominent issue i have found is that by default, your localhost folders are read only and you need to change permission as well.... Initially i thought read only wudnt matter if i am just loading the picture beacuse technically i am only reading the contents , right. But it did matter.
White Spaces
One more thing you coud check for is the name of your image containing white spaces, if they are then you need to remove white spaces from your image name while making URL request.
Try adding extensions if nothing works out
If eveythings fine , try to load the image with extensions which would obviously work.
Provide us with some initial coding as well
Let us know about your code snippets and console outputs which could help the community to reach the solution of the problem in a more prominent manner.

get the full image path of the image stored in the PhotoGallery

I want to get the full image path of the image stored in the PhotoGallery inside the iphone.How to get it? I used the image.nativePath But it's not working.. Please Help Thanks....
In my opinion, it is not possible.
You can only works on copy of photo
Edit : It should be possible to get the url of the file with:
- (NSURL *)url
of ALAssetRepresentation class
You can not access the actual path of the image, even if you get the path. Starting in iOS4 the access to the actual files is denied, while in iOS 3 it was possible.