//Calculate cache size on child threadsDispatch_async (Dispatch_get_global_queue (0,0), ^{//get the Cache folder pathUnsignedLong LongSize =file.filesize; Size+=[Sdimagecache sharedimagecache].getsize; NSString*sizetext =Nil; if(Size >= Pow (Ten,9)) {//size >= 1GBSizetext = [NSString stringWithFormat:@"%.2FGB", Size/pow (Ten,9)]; } Else if(Size >= Pow (Ten,6)) {//1GB > Size >= 1MBSizetext = [NSString stringWithFormat:@"%.2FMB", Size/pow (Ten,6)]; } Else if(Size >= Pow (Ten,3)) {//1MB > Size >= 1KBSizetext = [NSString stringWithFormat:@"%.2fkb", Size/pow (Ten,3)]; } Else{//1KB > SizeSizetext = [NSString stringWithFormat:@"%zdb", size]; }//Generate textNSString *text = [NSString stringWithFormat:@"Clear Cache (%@)", Sizetext]; //back to main threadDispatch_async (Dispatch_get_main_queue (), ^{ //Set Text //Restore Click eventsself.userinteractionenabled =YES; }); }); } returnSelf ;}
/** * Clear Cache*/- (void) clearcache{//Popup Indicator[Svprogresshud Showwithstatus:@"Clearing cache ..."Masktype:svprogresshudmasktypeblack]; //Delete the sdwebimage cache[[Sdimagecache Sharedimagecache] cleardiskoncompletion:^{ //Delete a custom cacheDispatch_async (Dispatch_get_global_queue (0,0), ^{Nsfilemanager*mgr =[Nsfilemanager Defaultmanager]; [Mgr Removeitematpath:file Error:nil]; [Mgr Createdirectoryatpath:xmgcustomcachefile withintermediatedirectories:yes attributes:nil Error:nil]; //all caches are cleared.Dispatch_async (Dispatch_get_main_queue (), ^{ //Hide Indicator[Svprogresshud dismiss]; //Set TextSelf.textLabel.text =@"Clear Cache (0B)"; }); }); }];}
Clear the implementation of the cache