慕田峪4524236
新手 使用plist文件吧,自己手动创建一个property list 文件 存储到程序中 用的时候读取就可以.数据库新手不建议使用SQLite或者Core Data自己去写,很容易出错.轻量级使用 FMDB(sqlite 封装)FMDB github 地址 可以到github上下载 查看里面的sample 例子的实现自己模仿偷偷告诉你一个很黄很暴力的存储方案TMCache (一键存储,一行代码存储,一行代码读取!)TMCache github 地址存:UIImage * img = [[UIImage alloc] initWithData:data scale:[[UIScreen mainScreen] scale]];
[[TMCache sharedCache] setObject:img forKey:@"image" block:nil]; // returns immediately读[[TMCache sharedCache] objectForKey:@"image"
block:^(TMCache *cache, NSString *key, id object) {
UIImage *image = (UIImage *)object;
NSLog(@"image scale: %f", image.scale);
}];
NSArray * images = @[ image, image, image ];
[[TMCache sharedCache] setObject:images forKey:@"images"];
NSLog(@"3 for the price of 1: %d", [[[TMCache sharedCache] diskCache] byteCount]);