如何将任何数据变成数据
我想将保存在Swift(fileManager)中。
。
它可能是一切,也是不符合代码的类型(例如scnnodes
)。
我想将其包裹在数据中。我知道,我无法使用propertyListenCoder
做到这一点。
您能让我容易理解它的工作原理吗?
I want to save Any?
in Swift (to FileManager).
It could be everything, also types that don't conform to Codable (like SCNNodes
).
I would like to wrap it into Data. I know, I can't do it with a PropertyListEncoder
.
Could you make it easy for me to understand how it works?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是。任何人的全部含义是它可能是任何东西。但是,不仅可以将任何东西都变成数据。这就是为什么像编码和nscoding这样的协议(scnnode符合的)以及为什么任何人都不能符合其中任何一个的原因。这些协议挑选出可以将 变成数据的类型。
It doesn't. The whole meaning of Any is that it could be anything. But not just anything can be turned into a Data. That is why protocols like Codable and NSCoding (to which SCNNode conforms) exist — and why Any cannot conform to either of them. These protocols pick out the types that can be turned into a Data.