Created
November 4, 2012 12:27
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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