Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
514 views
in Technique[技术] by (71.8m points)

macos - Portability of Core Data's SQLite file between OS X and iPhone OS

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.

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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):

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...