How to NSKeyedUnarchiver.unarchiveObject

后端 未结 2 547
梦毁少年i
梦毁少年i 2020-12-11 17:11

I have a working code that works but deprecated:

This part is fine:

 let archived = try? NSKeyedArchiver.archivedData(withRootObject: [defaultRecor         


        
相关标签:
2条回答
  • 2020-12-11 17:29

    The usage of the new API to archive an array is a bit tricky.

    You could have figured it out yourself if you wouldn't ignore the errors with try?

    0 讨论(0)
  • 2020-12-11 17:36

    The method above didn't worked for me for unarchiving, I did this and it worked:

    NSKeyedUnarchiver.unarchivedObject(ofClasses: [Record.self], from: archived)
    
    0 讨论(0)
提交回复
热议问题