1
let person = Person()
    person.name = "zhangzhe"
    person.age = 25
    print(self.home)
    do {
        try NSKeyedArchiver.archivedData(withRootObject: person, requiringSecureCoding: false)
    } catch {
        print(error)
    }

I want to set the path, so that i can find it again. But i cann't know what to do .. archiveRootObject(_ rootObject: Any, toFile path: String) the method is deprecated in iOS12

Zhe Zhang
  • 13
  • 3

1 Answers1

1

This might be helpful for iOS12

do {
  let data = try NSKeyedArchiver.archivedData(withRootObject: person, requiringSecureCoding: false)
  try data.write(to: url)
} catch {
  print("Couldn't write file")
}
NaveenReddy
  • 685
  • 5
  • 6