Created
November 30, 2011 07:31
-
-
Save yasirmturk/1408338 to your computer and use it in GitHub Desktop.
A generic core data function that inserts a new row for the given entity & fill that row with given key/values
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
/* | |
* A generic function that inserts a new row for the given entity and fill that row with given key/values | |
*/ | |
-(void)insertObjectForEntity:(NSString *)entityName objectsToInsert:(NSDictionary *)dictObjects | |
{ | |
NSError *error; | |
NSManagedObject *objToInsert = [NSEntityDescription insertNewObjectForEntityForName:entityName inManagedObjectContext:[self managedObjectContext]]; | |
for (id key in [dictObjects allKeys]) { | |
[objToInsert setValue:key forKey:[dictObjects objectForKey:key]]; | |
} | |
[[self managedObjectContext] save:&error]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment