Trygve
Trygve

Reputation: 1387

Decoding NSArchiver with NSKeyedUnarchiver

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?

Upvotes: 2

Views: 398

Answers (1)

Rob Napier
Rob Napier

Reputation: 299623

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.

Upvotes: 1

Related Questions