NSArchiver vs. NSKeyedArchiver
Asked Answered
S

1

11

How do you know if you need to use NSArchiver or NSKeyedArchiver? What's the difference?

Skippy answered 19/9, 2010 at 8:21 Comment(0)
A
13

NSArchiver supports the key-less coding methods like –encodeObject: or –decodePoint, while NSKeyedArchiver supports the key-based coding methods like –encodeObject:forKey: or –decodePointForKey:. The major difference is that on archivers, you need to decode stuff in exactly the same way as you encoded it. Every key can be decoded exactly once. Keyed archivers, on the other hand, do not restrict you to any order and you can freely decode the same object multiple times.

Whenever possible, use NSKeyedArchiver. It's newer and will probably eventually replace the non-key-based variant.

Apis answered 19/9, 2010 at 10:0 Comment(1)
Also, NSArchiver is not available for iPhone apps.Skippy

© 2022 - 2024 — McMap. All rights reserved.