Decoding NSArchiver with NSKeyedUnarchiver

316 views Asked by At

I have some old archives that are basically stored preferences created with NSArchiver. I want to be able to decode them with NSKeyedUnarchiver since the NSArchiver/NSUnarchiver are deprecated in favor of their keyed counterparts.

Is there any way to make this work?

1

There are 1 answers

0
Rob Napier On

You cannot decode an NSArchiver archive with NSKeyedUnarchiver. The NSArchiver format is deprecated, not just the classes. If you have data in the old format, you may have to use a deprecated class to decode it. The point is that you would then re-encode the data using NSKeyedArchiver (or one of the other options like Codable in Swift) and store it in a modern format.