swift 归档解档操作
来源:互联网 发布:php用qq邮箱发送邮件 编辑:程序博客网 时间:2024/06/05 18:08
import UIKit
class MallrroNurseInformation: NSObject,NSCoding {
let userAccountPath = “(NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory,FileManager.SearchPathDomainMask.userDomainMask,true).first!)/userAccount.data”
var name = String() //归档对象的属性值
// MARK:- 处理需要归档的字段
func encode(with aCoder:NSCoder
) {
aCoder.encode(“zhangsan”, forKey:”name”)
}
// MARK:- 处理需要解档的字段
required init(coder aDecoder:NSCoder
) {
super.init()
self.name = (aDecoder.decodeObject(forKey:”name”)as?String)!
}
override init() {
super.init()
}
//归档模型对象 personModel – 归档对应对象类(自己创建)
func archiveObject(pModel:personModel) -> Void {
NSKeyedArchiver.archiveRootObject(pModel, toFile:userAccountPath as String)
}
//读取模型对象
func unarchiveObject() -> personModel{
if (NSKeyedUnarchiver.unarchiveObject(withFile:userAccountPath as String) != nil) {
return (NSKeyedUnarchiver.unarchiveObject(withFile:userAccountPath as String)as? personModel)!
}
return self
}
}
- swift 归档解档操作
- swift归档解档
- Swift-归档解归档
- swift实现归档解档
- Swift 解档和归档
- iOS swift-归档与解档
- swift 本地归档、解档储存
- ios swift 归档解档遇到的坑 3-30
- 归档-swift
- 关于swift归档解档后台新增字段解档出来的nil的解决办法
- Swift实现对象归档
- 归档解档
- iOS解档归档
- iOS 解档归档
- 解档与归档
- 归档解档
- 归档与解档
- 快速归档解档
- Spring 高级装配
- UDT协议实现分析——UDT初始化和销毁
- 使用EventBus实现Activity与Fragment之间的跳转
- 日常2.0--关于EasyUI的坑(datagrid_1)
- UDT协议实现分析——UDT Socket的创建
- swift 归档解档操作
- android 高德地图系统签名后定位失败解析
- UDT协议实现分析——bind、listen与accept
- UDT协议实现分析——连接的建立
- 在C代码调用C++代码
- qiaoguanjia xinxi jiaoliu
- QUIC/HTTP2相关资料整理
- 时间复杂度和空间复杂度
- 欢迎使用CSDN-markdown编辑器