开发者

NSArchiver vs. NSKeyedArchiver

开发者 https://www.devze.com 2023-01-16 13:59 出处:网络
How do you know if you need to use NSArch开发者_如何学JAVAiver or NSKeyedArchiver? What\'s the difference?NSArchiver supports the key-less coding methods like –encodeObject: or –decodePoint, while N

How do you know if you need to use NSArch开发者_如何学JAVAiver or NSKeyedArchiver? What's the difference?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消