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.
我需要将 CoreData 对象转换为 NSData(通过 GameKit 将其发送到另一个应用程序)。
我尝试使用 NSKeyedArchiver 和 NSKeyedUnarchiver,但似乎归档和取消归档 CoreData 对象比普通对象更棘手。
我一直在研究 CoreData 文档,但还没有找到任何线索。有人可以指出我正确的文档或给我提示如何执行此操作吗?
提前致谢。
您可以为每个需要它的对象添加一个方法,该方法返回一个字典,其中包含您需要存储/发送的所有键和值。NSDictionary原生支持存档,所以一旦你有了字典,一切都照常。这可能比尝试直接将归档改型到托管对象子类中的代码更少且更灵活。
NSDictionary