Making calls and clearing the cache

Source: Internet
Author: User

NSLog (@ "Customer service phone");

Uiwebview*callwebview =[[uiwebview alloc] init];

Nsurl *telurl =[nsurl urlwithstring:@ "tel:400-041-5656"];//looks like tel://or Tel: All right

[Callwebview loadrequest:[nsurlrequest Requestwithurl:telurl];

Remember to add to the view

[Self.view Addsubview:callwebview];

Get the size of the cache file

Because the cache file exists in the sandbox, we can use the Nsfilemanager API to calculate the size of the cache file.

Calculate a single File size

Calculate Directory Size
+ (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 +=[fileservice Filesizeatpath:absolutepath];     }  // Implementation of Sdwebimage framework self-calculation cache     foldersize< Span class= "RegExp" >+=[[sdimagecache Sharedimagecache] Getsize]/1024.0/ 1024.0;     return foldersize;  }  return 0;}      
Clean up cache files

Also using the Nsfilemanager API for file operations, the Sdwebimage framework itself implements the cleanup cache operation, which we can call directly.

+ (void) ClearCache: (nsstring*) path{Nsfilemanager*filemanager=[nsfilemanager Defaultmanager];if ([FileManager Fileexistsatpath:path]) {   nsarray *childerfiles=[filemanager Subpathsatpath:path];    for (nsstring * FileName in Childerfiles) {      //if necessary, join the conditions, filter out files that you do not want to delete        nsstring *absolutepath=[path stringbyappendingpathcomponent: FileName];       [filemanager removeItemAtPath: Absolutepath Error:nil];     }  }   [[Sdimagecache Sharedimagecache] cleandisk];}           

Making calls and clearing the 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.