将数据流读取到托管对象上下文中?
我见过一种巧妙的方法,可以通过沙箱将用户数据从一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您发送整个 .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.NSManagedObjectID
s are preferable if you have two stacks already pointing to the same URL (that you created theNSManagedObjectModel
with, and subsequently init'ed theNSPersistentStoreCoordinator
with by[[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]
.