NSKeyedArchiver 我应该如何在 iOS12 中设置路径
NSKeyedArchiver how should i set path in iOS12
let person = Person()
person.name = "zhangzhe"
person.age = 25
print(self.home)
do {
try NSKeyedArchiver.archivedData(withRootObject: person, requiringSecureCoding: false)
} catch {
print(error)
}
我想设置路径,以便我可以再次找到它。
但我不知道该怎么办..
archiveRootObject(_ rootObject: Any, toFile path: String) 该方法已在 iOS12
中弃用
这可能对 iOS12
有帮助
do {
let data = try NSKeyedArchiver.archivedData(withRootObject: person, requiringSecureCoding: false)
try data.write(to: url)
} catch {
print("Couldn't write file")
}
let person = Person()
person.name = "zhangzhe"
person.age = 25
print(self.home)
do {
try NSKeyedArchiver.archivedData(withRootObject: person, requiringSecureCoding: false)
} catch {
print(error)
}
我想设置路径,以便我可以再次找到它。 但我不知道该怎么办.. archiveRootObject(_ rootObject: Any, toFile path: String) 该方法已在 iOS12
中弃用这可能对 iOS12
有帮助do {
let data = try NSKeyedArchiver.archivedData(withRootObject: person, requiringSecureCoding: false)
try data.write(to: url)
} catch {
print("Couldn't write file")
}