备份核心数据,仅一个实体
我的应用程序需要某种数据备份和用户之间的某种数据交换,因此我要实现的是能够导出实体,而不是整个数据库。
我找到了一些帮助,但是对于完整的数据库,例如这篇文章:
这适用于整个数据库。
我试图导出一个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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看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.