Skip to content

Instantly share code, notes, and snippets.

@fgarcia
Created November 4, 2012 12:27
Show Gist options
  • Save fgarcia/4011699 to your computer and use it in GitHub Desktop.
Save fgarcia/4011699 to your computer and use it in GitHub Desktop.
Open file and run a #core-data query with all #lowlevel details shown
id error;
NSManagedObjectModel *mom = [NSManagedObjectModel mergedModelFromBundles:nil];
NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
NSURL *file_url = [NSURL URLWithString:@"file://localhost/private/tmp/store.sqlite"];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSPersistentStore *store_dil = [psc addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:file_url
options:options
error:&error];
NSManagedObjectContext *moc = [[NSManagedObjectContext alloc] init];
[moc setPersistentStoreCoordinator:psc];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"MyEntity"
inManagedObjectContext:moc];
[request setEntity:entity];
NSArray *a = [moc executeFetchRequest:request error:&error];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment