0122 Clear Cache

Source: Internet
Author: User

Start

-(void) clearcashself{

Mclog (@ "nshomedirectory sandbox path----%@", nshomedirectory ());

Uialertview *alert = [[Uialertview alloc] initwithtitle:@ "Clear Cache" message: [NSString stringwithformat:@ "Clear%.2fm", FileS Izem] delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK", nil];

Uialertview *alert = [[Uialertview alloc] initwithtitle:@ "clear local cache" message: [NSString stringwithformat:@ "Clear%.2fkb", Filesizem] delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK", nil];

Alert.tag = 8899;

[Alert show];

}

-(float) Filesizeatpath: (NSString *) path{

Nsfilemanager *filemanager=[nsfilemanager Defaultmanager];

if ([FileManager Fileexistsatpath:path]) {

Long long Size=[filemanager Attributesofitematpath:path error:nil].filesize;

return size/1024.0/1024.0;

return size/1024.0;

}

return 0;

}

-(float) Foldersizeatpath: (NSString *) path{

Nsfilemanager *filemanager=[nsfilemanager Defaultmanager];

float foldersize;

if ([FileManager Fileexistsatpath:path]) {

Nsarray *childerfiles=[filemanager Subpathsatpath:path];

For (NSString *filename in childerfiles) {

NSString *absolutepath=[path Stringbyappendingpathcomponent:filename];

Foldersize +=[self Filesizeatpath:absolutepath];

}

return foldersize;

}

return 0;

}

-(void) ClearCache: (NSString *) path{

Nsfilemanager *filemanager=[nsfilemanager Defaultmanager];

if ([FileManager Fileexistsatpath:path]) {

Nsarray *childerfiles=[filemanager Subpathsatpath:path];

For (NSString *filename in childerfiles) {

If necessary, add conditions to filter out files that you do not want to delete

NSString *absolutepath=[path Stringbyappendingpathcomponent:filename];

[FileManager Removeitematpath:absolutepath Error:nil];

}

}

[[Sdimagecache Sharedimagecache] cleandisk];

}

[Self clearcashself];

Nsarray *paths = Nssearchpathfordirectoriesindomains (Nscachesdirectory, Nsuserdomainmask, YES);

NSString *cachpath = [Paths objectatindex:0];

[Self clearcache:cachpath];

filesizem=0;

[Tvdataarray removeallobjects];

[_tvsatand Reloaddata];

0122 Clear Cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.