-
iOS清除缓存
- #pragma mark === 暂时不用清除缓存=====
- -(void)myClearCacheAction{
- dispatch_async(
- dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
- , ^{
- NSString *cachPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
-
- NSArray *files = [[NSFileManager defaultManager] subpathsAtPath:cachPath];
- NSLog(@"files :%lu",(unsigned long)[files count]);
- for (NSString *p in files) {
- NSError *error;
- NSString *path = [cachPath stringByAppendingPathComponent:p];
- if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
- [[NSFileManager defaultManager] removeItemAtPath:path error:&error];
- }
- }
- [self performSelectorOnMainThread:@selector(clearCacheSuccess) withObject:nil waitUntilDone:YES];});
- }
-
-
- -(void)clearCacheSuccess
- {
- NSLog(@"清理成功");
-
- }
-
-
-
- CGFloat fileSize = [self folderSizeAtPath:cachePath];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- cache.subtitle = [NSString stringWithFormat:@"%.2fMB",fileSize];
- [self.tableView reloadData];
-
- });
-
-
- - (CGFloat)folderSizeAtPath:(NSString *)folderPath
- {
- NSFileManager *manager = [NSFileManagerdefaultManager];
- if (![manager fileExistsAtPath:folderPath]) {
- return 0;
- }
-
- NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath:folderPath] objectEnumerator];
-
- NSString *fileName = nil;
- long long folderSize = 0;
- while ((fileName = [childFilesEnumerator nextObject]) != nil) {
- NSString *fileAbsolutePath = [folderPath stringByAppendingPathComponent:fileName];
- folderSize += [self fileSizeAtPath:fileAbsolutePath];
- }
- return folderSize/(1024.0*1024.0);
- }
-
- - (long long)fileSizeAtPath:(NSString *)filePath
- {
- NSFileManager* manager = [NSFileManagerdefaultManager];
- if ([manager fileExistsAtPath:filePath]){
- return [[manager attributesOfItemAtPath:filePath error:nil] fileSize];
- }
- return 0;
-
- }
-
相关阅读:
分页的实现
调取地图map
meta标签应用,适应手机屏幕以及关键词、描述的添加
页面中公共部分的统一调用
PC端变成手机端的时候,把特效去掉(把canvas标签去掉)
IIS上绑定域名,发布上线
动态截取字符串获取当前网页的URL地址
Vue 打包后报错 Uncaught TypeError: Cannot redefine property: $router
Vue项目部署到线上页面空白
让从后台返回的数据在让elementui 的el-select 显示对应的label值而不是value值
-
原文地址:https://www.cnblogs.com/konglei/p/5087225.html
Copyright © 2020-2023
润新知