Core Data 的 SQLite 文件在 OS X 和 iPhone OS 之间的可移植性 [英] Portability of Core Data's SQLite file between OS X and iPhone OS

查看:15
本文介绍了Core Data 的 SQLite 文件在 OS X 和 iPhone OS 之间的可移植性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 iPhone 上使用 Core Data 的现有应用程序.有时,应用程序数据的更新会作为 App Store 的更新传送.在我的完美世界中,使用 OS X 应用程序构建一个应用程序来编辑更新中的数据并将 sqlite 数据库复制到我的 iPhone 应用程序包中,这将是一种相对轻松的方法.

I have an existing application using Core Data on the iPhone. Occasionally there would be updates to the application's data delivered as updates to the App Store. In my perfect world, building an application to edit the data in the updates with an OS X application and copying the sqlite database to my iPhone app bundle would be a relatively pain-free way to do this.

是否可以在 OS X 和 iPhone OS 之间移动 sqlite 数据库(假设它们使用相同的数据模型)?

Is it possible to move sqlite database (assuming they use the same data model) between OS X and iPhone OS?

我应该注意哪些不能在两者之间移植的东西(例如 32 位与 64 位数据)?

What are the things I should watch out for that isn't portable between (like 32-bit vs. 64-bit data)?

是否有我忽略的更好的替代方案?

Are there better alternatives that I'm overlooking?

推荐答案

具有相同数据模型的 Mac 和 iPhone 应用程序的 SQLite 格式是相同的.生成一个 Mac 应用程序来编辑您的数据库非常简单(我为我的 iPhone 应用程序执行此操作).事实上,您可以使用您的数据模型并为其快速拖放一个界面(来自 核心数据编程指南常见问题):

The SQLite format is identical between Mac and iPhone applications with the same data model. It's pretty trivial to generate a Mac application to edit your database (I do this for my iPhone application). In fact, you can take your data model and quickly drag and drop an interface for it (from the Core Data Programming Guide FAQ):

在 Mac OS X v10.5 及更高版本中,在Interface Builder你可以拖一个Core数据实体项目从库到一个窗口或盒子.界面生成器然后呈现一个面板,允许您从当前打开的 Xcode 项目.

In Mac OS X v10.5 and later, in Interface Builder you can drag a Core Data Entity item from the Library onto a window or box. Interface Builder then presents a panel that allows you to select the entity you want from the currently-open Xcode projects.

请注意,您还可以创建和配置一个 NSController 实例界面生成器.在这种情况下创建用户界面,您按住 Option 键单击数据中的实体Xcode 中的建模工具(或选择核心数据实体项目来自库),但您将其拖到界面生成器文件窗口.为了编辑一个对象,一个NSObjectController 实例是创造;为了编辑许多对象,一个创建 NSArrayController 实例.

Note that you can also create and configure an NSController instance in Interface Builder. As in the case of creating a user interface, you Option-click an entity in the Data Modeling tool in Xcode (or select the Core Data Entity item from the Library), but you drag it to a the Interface Builder file window. For editing one object, an NSObjectController instance is created; for editing many objects, an NSArrayController instance is created.

我还会查看核心数据编辑器,它会加载到您编译的托管对象模型中并让您从中编辑您的数据库.

I'd also check out Core Data Editor, which loads in your compiled managed object model and lets you edit your database from that.

这篇关于Core Data 的 SQLite 文件在 OS X 和 iPhone OS 之间的可移植性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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