What is the difference between .sqlite and .storedata

When you launch a new iOS project on Xcode using basic data, it initializes the database with the extension .sqlite. When you do the same for a new project for OSX, the database has an extension .storedata.

Is there a difference between the two? Thank you

+4
source share
1 answer

CoreData on iOS only supports sqlite persistent storage. CoreData in OS X supports several formats, including sqlite and xml, with persistent storage being xml-based by default. So .sqlite is sqlite persistent storage for CoreData, while .storedata is xml persistent storage.

, sqlite , xml () . , , . Mac, .

sqlite xml, persistentStoreCoordinator :

NSURL *url = [applicationFilesDirectory URLByAppendingPathComponent:@"Foo.storedata"];
NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
if (![coordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:nil error:&error]) {

NSURL *url = [applicationFilesDirectory URLByAppendingPathComponent:@"Foo.sqlite"];
NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
if (![coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:nil error:&error]) {
+8

Source: https://habr.com/ru/post/1536849/


All Articles