1. Find the Sdimagecache class
2. Add the following method:
[OBJC]View Plaincopyprint?
- -(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;
- }
-(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/1024.0; } NSLog (@ "tmp size is%.2f", totalsize); return totalsize;}
3. Use in Settings like this
[OBJC]View Plaincopyprint?
- #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];
- }