Sha256: aab0b6d54b04f58ef1ddff001483f2f1c671e64ec74bb0d619ac6cb24df85a9f
Contents?: true
Size: 1.41 KB
Versions: 8
Compression:
Stored size: 1.41 KB
Contents
// // AppDelegate+Frank.m // QlikView // // Created by Matt Brooke-Smith on 18/07/2012. // Copyright (c) 2012 Future Workshops. All rights reserved. // #import "AppDelegate+Frank.h" #import <CoreData/CoreData.h> #import <JSONKit/JSONKit.h> #import <RestKit/RestKit.h> #import "RKObjectManager+QVWOfflineTests.h" @implementation AppDelegate (Frank) - (void) seedCoreData:(NSString *)json { NSArray *objectsArray = [json objectFromJSONString]; NSManagedObjectContext *managedObjectContext = [[RKObjectManager sharedManager].objectStore managedObjectContextForCurrentThread]; for (NSDictionary *objectDictionary in objectsArray) { NSString *entityName = [objectDictionary allKeys][0]; NSDictionary *dictionary = [objectDictionary objectForKey:entityName]; NSManagedObject *object = [NSEntityDescription insertNewObjectForEntityForName:entityName inManagedObjectContext:managedObjectContext]; for (NSString *nextKey in [dictionary allKeys]) { if ([object respondsToSelector:NSSelectorFromString(nextKey)]) { NSObject *value = [dictionary objectForKey:nextKey]; if (value != [NSNull null]) { [object setValue:value forKey:nextKey]; } } } } NSError *error = nil; if (![managedObjectContext save:&error]) { WLog(@"Error saving: %@", [error localizedDescription]); } } @end
Version data entries
8 entries across 8 versions & 1 rubygems