标签:ios
[NSKeyedArchiver archiveRootObject:model toFile:path];
[NSKeyedUnarchiver unarchiveObjectWithFile:path];
好方便,不过总感觉体验不好,测了下方法时间,当model量大后解析时间基本在200ms以上了,放弃使用[[WTUtilsshared].db clearTable:@"RestList"];
[[WTUtilsshared].db putObject:responsewithId:@"restList"intoTable:@"RestList"];
再结合今天看的Mantle
- (void)loadSavedData {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
id data = [[WTUtils shared].db getObjectById:@"restList" fromTable:@"RestList"];
restListArray = [WTRestListEntity getRestListArray:data];
if (restListArray != nil) {
DELAYEXECUTE(0.0, [_tableView reloadData]);
}else {
[ZAActivityBar showWithStatus:@"loading..."];
}
});
}最后缓存效果不错,代码操作简单,可操作性好.
标签:ios
原文地址:http://blog.csdn.net/rainlesvio/article/details/40897985