1. First to find the Sdimagecache class, can be the following methods
2. Add the following method:
[OBJC]View Plaincopy
- -(float) checktmpsize
- {
- float totalsize = 0;
- nsdirectoryenumerator *fileenumerator = [[Nsfilemanager Defaultmanager] Enumeratoratpath:diskcachepath] ;
- For (nsstring *filename in fileenumerator)
- {
- nsstring *filepath = [Diskcachepath stringbyappendingpathcomponent:filename];
- nsdictionary *attrs = [[Nsfilemanager Defaultmanager] attributesofitematpath:filepath error: nil] ;
- Unsigned long long length = [Attrs fileSize];
- TotalSize + = length/ 1024. 0/ 1 0 24. 0;
- }
- NSLog (@ "tmp size is%.2f", totalsize);
- return totalsize;
- }
This method has been added to the new Sdimagecache class
[OBJC]View Plaincopy
- [[Sdimagecache Sharedimagecache] getsize];
3. Use in Settings like this
[OBJC]View Plaincopy
- #pragma clean up cached pictures
- -(void) Cleartmppics
- {
- [[Sdimagecache Sharedimagecache] Cleardisk];
- [[Sdimagecache Sharedimagecache] clearmemory];//dispensable
- DLog (@ "clear disk");
- float tmpsize = [[Sdimagecache Sharedimagecache] checktmpsize];
- nsstring *clearcachename = tmpsize >= 1? [NSString stringWithFormat:@ "Clean cache (%.2FM)", tmpsize]: [NSString stringWithFormat:@ "Clean cache (%.2FK)", tmpsize * 1024];
- [Configdataarray Replaceobjectatindex:2 withobject:clearcachename];
- [Configtableview Reloaddata];
- }
How to manually clear the cache in iOS Sdwebimage technology sharing