如何将任何数据变成数据

发布于 2025-01-23 13:33:02 字数 202 浏览 7 评论 0原文

我想将保存在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小伙你站住 2025-01-30 13:33:02

您能让我很容易理解它的工作原理吗?

不是。任何人的全部含义是它可能是任何东西。但是,不仅可以将任何东西都变成数据。这就是为什么像编码和nscoding这样的协议(scnnode符合的)以及为什么任何人都不能符合其中任何一个的原因。这些协议挑选出可以将 变成数据的类型。

Could you make it easy for me to understand how it works?

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文