Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)requestDidFinishLoad:(TTURLRequest*)request {
- ...
- ... //read your JSON into a NSDictionary
- NSManagedObjectContent* context = appDelegate.managedObjectContext;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- for (NSDictionary* itemInfo in jsonItems) {
- DBResource *resource = (DBResource*)[NSEntityDescription insertNewObjectForEntityForName:@"MyEntity" inManagedObjectContext:context];
- resource.id = [itemInfo valueForKey:@"id"];
- resource.name = [itemInfo valueForKey:@"name"];
- }
- NSError *error;
- if( ![context save:&error] ) {
- // handle error
- }
- [context reset];
- [pool drain];
- ... // other cleanup
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement