NSCache
来源:互联网 发布:正规贵金属行情软件 编辑:程序博客网 时间:2024/05/18 00:05
NSCache
示例代码如下
#import "ViewController.h"@interface ViewController ()@property (nonatomic, strong)NSCache* cache;@end@implementation ViewController-(NSCache *)cache{ if (_cache==nil) { _cache=[[NSCache alloc]init]; _cache.totalCostLimit=5; } return _cache;}- (IBAction)addBtn:(id)sender { for (NSInteger i=0; i<10; i++) { NSData *data=[NSData dataWithContentsOfFile:@"/Users/spencer/Desktop/QQ20170218-175829.png"]; [self.cache setObject:data forKey:@(i) cost:1]; NSLog(@"存入了图片%zd",i); } }- (IBAction)checkBtn:(id)sender { NSLog(@"+++++++++++++++++++++++="); for (NSInteger i=0; i<10; i++) { NSData *data=[self.cache objectForKey:@(i)]; if (data) { NSLog(@"取出了数据%zd",i); } }}- (IBAction)removeAll:(id)sender { [self.cache removeAllObjects]; }@end
0 0
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache
- NSCache缓存
- NSCache小结
- NSCache和NSURLCache
- iOS 导航栏返回按钮自定义
- 黑盒测试基本方法
- 重温jvm中的happen-before
- 初学反射
- 分享一个微信公众号id转换为biz的接口
- NSCache
- Android笔记2016_04_01
- Eilxir解决哲学家就餐问题
- 复制字符串
- 文章标题
- Tomcat访问路径去掉发布项目的项目目录
- AndroidStudio的日常使用——快捷键
- StringBuffer的用法
- Linux.配置Hadoop环境的一些问题解决