将数据流读取到托管对象上下文中?

发布于 2025-01-07 07:11:17 字数 521 浏览 2 评论 0原文

我见过一种巧妙的方法,可以通过沙箱将用户数据从一个 iOS 应用程序升级到另一个应用程序;目标应用程序注册为特殊的 URL 处理程序,源应用程序对整个文件进行 Base64 编码,并将其作为纯文本字符串发送到专用 URL,目标应用程序将其解码并保存到文件系统。

是否可以对源的托管对象上下文进行编码?发送该&目标是否将其解析为托管对象上下文?也就是说,不是覆盖目的地数据,而是合并传入数据?这个问题的答案只是“您可以对传入的数据做任何您想做的事情”吗?

编辑:

我还没有使用过,但计划使用讨论的 data-to-text-to-url-to-url-handler-to-data 方法 此处。假设这有效,我的问题是,目标是否可以将数据解析为我插入到目标托管对象上下文中的托管对象?起点和终点具有相同的管理对象模型。

I have seen a slick method for upgrading user data from one iOS app to another across the sandboxes; the destination app registers as a special URL handler and the origin app base64-encodes an entire file and sends it as a plaintext string to the specialized URL, which the destination app decodes and saves to filesystem.

Is it possible to encode the origin's managed object context & send that & have the destination parse that into it's managed object context? That is, instead of over-writing the destinations data, merge the incoming data? Is the answer to this question simply "You can do whatever you want with the incoming data"?

EDIT:

I have not used but am planning on using the data-to-text-to-url-to-url-handler-to-data method discussed here. ASSUMING that this works, my question is I guess, can the destination parse the data as managed objects that I insert into the destination managed object context? The origin and destination have the same managed object model.

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

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

发布评论

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

评论(1

南烟 2025-01-14 07:11:17

如果您发送整个 .sqlite 文件本身的内容,您尝试做的事情可能是可能的。您必须让您的目标应用程序从保存到目标沙箱中的文件构建整个(即 NSPercientObjectStoreCoordinator)核心数据堆栈。如果您有两个堆栈已指向同一个 URL(您使用该 URL 创建了 NSManagedObjectModel,并随后初始化了 NSPercientStoreCoordinator),则最好使用 NSManagedObjectID > 通过 [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]

What you are trying to do may be possible if you send the contents of the entire .sqlite file itself. You would have to have your destination app build up an entire (i.e. NSPersistentObjectStoreCoordinator) Core Data stack from the file that got saved into the destination sandbox. NSManagedObjectIDs are preferable if you have two stacks already pointing to the same URL (that you created the NSManagedObjectModel with, and subsequently init'ed the NSPersistentStoreCoordinator with by [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model].

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