• ios开发--清理缓存


    ios文章原文

    一段清理缓存的代码如下:

    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 :%d",[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:nilwaitUntilDone:YES];});

     

    -(void)clearCacheSuccess

    {

        NSLog(@"清理成功");

    }

     

    #define kBundleName @"MJRefresh.bundle"

    #define kSrcName(file) [kBundleName stringByAppendingPathComponent:file]

    调用:[UIImageimageNamed:kSrcName(@"arrow.png")];

    创建一个文件夹,后缀名为bundle,图片和一些资源文件可以放里面

  • 相关阅读:
    nginx解决前端跨域配置
    oracle 空表处理
    (转)Oracle修改表空间为自动扩展
    使用silverlight自定义控件时“给定关键字不在字典中”
    arcengine note:
    Jquery CSS 操作
    Jquery Easy-UI 树形菜单的运用
    Easy-UI data-options总结
    数据库 存储过程初探
    ASP.NET 日志的记录(登录日志和异常日志和操作日志)
  • 原文地址:https://www.cnblogs.com/wanghuaijun/p/5411748.html
Copyright © 2020-2023  润新知