备份核心数据,仅一个实体

发布于 2025-01-29 12:04:26 字数 424 浏览 1 评论 0原文

我的应用程序需要某种数据备份和用户之间的某种数据交换,因此我要实现的是能够导出实体,而不是整个数据库。

我找到了一些帮助,但是对于完整的数据库,例如这篇文章:

本地备份核心数据,然后从备份还原 - Swift

这适用于整个数据库。

我试图导出一个JSON文件,这可能起作用,除了我试图导出的实体包含图像作为二进制数据。

所以我卡住了。

任何帮助导出而不是完整数据库,而只是一个实体或如何编写包含二进制数据的JSON。

My application requires some kind of data backup and some kind of data exchange between users, so what I want to achieve is the ability to export an entity but not the entire database.

I have found some help but for the full database, like this post:

Backup core data locally, and restore from backup - Swift

This applies to the entire database.

I tried to export a JSON file, this might work except that the entity I'm trying to export contains images as binary data.

So I'm stuck.

Any help exporting not the full database but just one entity or how to write a JSON that includes binary data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

风启觞 2025-02-05 12:04:26

看看Protobuf。苹果有一个官方的Swift Lib,

https://github.com/apple/swift-protlobuf

ProtoBuf是对JSON的替代编码,该编码直接支持序列化二进制数据。如果您想手动检查文件,则有任何可能需要读取数据或命令行工具的语言的客户库。

Take a look at protobuf. Apple has an official swift lib for it

https://github.com/apple/swift-protobuf

Protobuf is an alternate encoding to JSON that has direct support for serializing binary data. There are client libraries for any language you might need to read the data in, or command-line tools if you want to examine the files manually.

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