开发者

Creating .sqlite file from Core Data store?

I've seen tutorials in books and on websites that offer .sqlite files for download. The sqlite files are used for Core Data.

How do I get a .sqlit开发者_开发技巧e file FROM an app or core data store on TO my desktop?


If you are going to create a pre-populated sqlite file to be used with Core Data then you must create it with Core Data. It is trivial to create a basic desktop application for data entry and use that to create the file and then embed it in your iOS device.

Do not attempt to duplicate the data structure or linkage within the file by hand. You might get it to work but you will spend way more time trying to get it to work and it is going to eventually fail. The internal structure of a Core Data sqlite file should be considered like a private API. The structure is not public and can change without notice.


If you are specifically trying to create a Core Data store, you use this method:

NSPersistentStoreCoordinator 
    addPersistentStoreWithType:(NSString*)storeType 
    configuration:(NSString*)configuration
    URL:(NSString*)storeURL 
    options:(NSDictionary*)options
    error:(NSError**)error

You must have already associated a NSManagedObjectModel with your persistent store coordinator object. If the store at storeURL does not exist, it will be created; otherwise it will be opened.


These might help: http://www.sqlite.org/cvstrac/wiki?p=ManagementTools


I like to use this Firefox plugin: https://addons.mozilla.org/en-US/firefox/addon/5817/

You can create a new .sqlite file, change existing databases, and browse through your data.


There's a command line program download-able from sqlite.org (in the standard download) that can be used to create a blank database with a schema. Usually the database file is compatible across operating systems and devices.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜