标签:
1、archive 归档
数据的保存
1: let result = NSKeyedArchiver.archiveRootObject(contacts, toFile: path as String)2: println("保存结果\(result)")
数据的读取:
1: var t:[Contact]?
2: var any:AnyObject? = NSKeyedUnarchiver.unarchiveObjectWithFile(path as String)3: if any == nil {4: t = [Contact]()
5: }else{6: println("读取成功")7: t = any as? [Contact]8: }
需要在模型中实现init With Coder方法 和 encodewithCoder方法
2、User Default
3、plist 存储
1: [dataDic setValue:eachDArray forKey:"key"];
2: [dataDic writeToFile:filename atomically:YES];
标签:
原文地址:http://www.cnblogs.com/zeyang/p/4491708.html