Skip to content

Instantly share code, notes, and snippets.

@logicaroma
Created April 8, 2011 12:24
Show Gist options
  • Save logicaroma/909727 to your computer and use it in GitHub Desktop.
Save logicaroma/909727 to your computer and use it in GitHub Desktop.
//CORE DATA
//FETCHING PROCESS SNIPPET
NSManagedObjectContext *sharedContext = [(AppDelegate_Shared *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Currency" inManagedObjectContext:sharedContext];
[request setEntity:entity];
currencies = [[NSArray alloc ] initWithArray:[sharedContext executeFetchRequest:request error:nil]];
//INSERTING PROCCESS
if([currencies count] == 0){
Currency *gbp = (Currency *)[NSEntityDescription insertNewObjectForEntityForName:@"Currency" inManagedObjectContext:sharedContext];
gbp.name = @"British Pounds";
gbp.code = @"GBP";
[sharedContext save:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment