iOS 数据存储之我见
引言:
iOS的数据存储与缓存涉及到的知识方方面面,有蛮多需要去好好了解了解,那么做为移动设备的应用,离线数据的重要性,相对于PC应用显得重要的多.
文中介绍的方法,不一定都是最好的,但都是目前博主都在使用的技术,如果有更好的方法和技术,不吝赐教!
参考资料:
1:使用Keychain存储用户敏感信息
http://blog.csdn.net/tianyitianyi1/article/details/7643365
2:NSUserDefaults简介及使用
http://qing.blog.sina.com.cn/2739139371/a343f32b33001kpq.html
介绍:
1: KeyChain
//通过文件路径获取
NSMutableDictionary *attachmentInfoDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:attachmentInfoPathString];
//判断是否成功从指定的路径中取到Plist 文件,如果没有,则实例化一个新的供写入
if (attachmentInfoDictionary == nil) {
attachmentInfoDictionary = [[NSMutableDictionary alloc] init];
}
[attachmentInfoDictionary setObject:@"值" forKey:@"键"];
NSLog(@"%@",attachmentInfoDictionary);
//返回是否写入成功 但是需要确保指定的路径结构存在,否则肯定失败
[attachmentInfoDictionary writeToFile:attachmentInfoPathString atomically:NO];
[attachmentInfoDictionary release];
[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]
[[NSUserDefaults standardUserDefaults] synchronize];
4:Core Data
总结: