Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
根据我的理解,完整的对象图使用以下方式存储:
NSKeyedArchiver archiveRootObject
并且它以与保存相同的顺序被检索,这是正确的吗?
我得到一个 NSDictionary 并希望以与接收对象相同的顺序保存对象。
如果您的 NSDictionary 包含一个数组(如您在对不同答案的评论中所述),则该数组将被保留。NSKeyedArchiver 只是保存对象,它与订单没有任何关系。所以回答你的问题,是的。
NSDictionary 中元素的顺序是未定义的,因此即使您以与写入时相同的顺序读取它们,然后遍历它们,顺序也可能与最初的不同。