NSPersistentDocument和UIManagedDocument是否兼容? [英] Are NSPersistentDocument and UIManagedDocument compatible?

查看:122
本文介绍了NSPersistentDocument和UIManagedDocument是否兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Mac OS X中创建一个NSPersistentDocument,并在iOS 7上将该文档作为UIManagedDocument读取.

I would like to create a NSPersistentDocument in Mac OS X and read this document as a UIManagedDocument on iOS 7.

这可能吗?

两种文件格式兼容吗?

谢谢!

推荐答案

有趣的问题-我可以确认基本核心数据文件兼容.我有一个Mac应用程序和一个iOS应用程序,使用的是使用iCloud同步的同一文件.该应用程序是基于文档的应用程序,目前我已经将实际的数据库文件存储在iCloud中,因此整个文件都由iCloud进行了同步.

Interesting question - I can confirm that the basic core data files are compatible. I have a Mac app and an iOS app using the same file that gets synced using iCloud. The app is a document based app and currently I have been storing the actual database file in iCloud so the whole file gets sync'ed by iCloud.

这很好用,但是很明显,如果用户在两个设备上打开文件并且不小心保存和关闭文件,则他们的更改可能会被覆盖.

This works fine but obviously if a user opens the file on two devices and is not careful about saving and closing there is a possibility their changes may be overridden.

Apple已批准使用标准NSPersistentDocument创建和保存文件的Mac应用.不幸的是,他们拒绝iOS应用程序,因为它们带有一些晦涩的参考,因为它们不符合其数据存储准则,他们说如果文档需要备份到iCloud,则必须将它们存储在/Documents目录中.好吧,如果用户选择了iCloud,那么我会将文件存储在API调用提供的iCloud位置.

Apple has approved the Mac app which uses standard NSPersistentDocument to create and save files. Unfortunately they have rejected the iOS apps with some obscure reference to not conforming to their data storage guidelines, saying that documents must be stored in /Documents directory if they need to be backed up to iCloud. Well if the user has selected iCloud then I store the files in the iCloud location provided by the API calls.

无论如何,我仍然在等待他们的反馈,以了解这种方法到底有什么问题,因为它似乎与Pages和其他基于文档的应用程序所使用的相同.

Anyway I am still waiting to hear back from them about what is specifically wrong with this approach since it seems to be the same one used by Pages and other document based apps.

如果我尝试使用UIManagedDocument,则iOS创建文件夹结构并将数据库存储在此文件夹结构内.然后,Mac应用程序的文件"->打开"对话框将显示此文件夹结构以及一个看起来像普通sqlite文件的文件.但是也许OS X 10.8.4并没有实现最新的iCloud/Core Data东西-谁知道...

If I try using UIManagedDocument then iOS creates a folder structure and stores the database inside this folder structure. The Mac app File->Open dialog then shows this folder structure as well as a file that essentially looks like a the normal sqlite file. But then perhaps OS X 10.8.4 does not implement the latest iCloud/Core Data stuff - who knows...

编辑 这是代码示例和视频的链接,这些示例和视频显示了使用Core Data和iCloud集成OSX和iOS应用程序. http://ossh.com.au/design-和技术/软件开发/uimanageddocument-icloud-integration/

EDIT Here is a link to code examples and videos showing OSX and iOS app integration using Core Data and iCloud. http://ossh.com.au/design-and-technology/software-development/uimanageddocument-icloud-integration/

这篇关于NSPersistentDocument和UIManagedDocument是否兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆