Note that there are some explanatory texts on larger screens.

plurals
  1. PORestkit & CoreData Error. Failed to call designated initializer on NSManagedObject
    text
    copied!<p>I am changing my app from using a purely remote DB to pulling the remote DB into a local DB. I am getting this Error when I am trying to get an Array of Objects from the remote database.</p> <p><code>CoreData: error: Failed to call designated initializer on NSManagedObject class 'Class'</code></p> <p>I am not sure what I am doing wrong. Here is my restkit setup.</p> <pre><code>RKObjectManager *manager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://fake.herokuapp.com"]]; NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"App" withExtension:@"momd"]; NSManagedObjectModel *managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel]; manager.managedObjectStore = managedObjectStore; RKEntityMapping *classMapping = [RKEntityMapping mappingForEntityForName:@"Class" inManagedObjectStore:managedObjectStore]; [classMapping addAttributeMappingsFromDictionary:[Class propertyMappings]]; NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful); RKResponseDescriptor *classDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:classMapping pathPattern:@"/class.json" keyPath:@"" statusCodes:statusCodes]; [manager addResponseDescriptorsFromArray:@[classDescriptor]]; [managedObjectStore createManagedObjectContexts]; managedObjectStore.managedObjectCache = [[RKInMemoryManagedObjectCache alloc] initWithManagedObjectContext:managedObjectStore.persistentStoreManagedObjectContext]; [RKObjectManager setSharedManager:manager]; </code></pre> <p>And here is the request I am making, where it fails ( i think on the response).</p> <pre><code> [manager getObjectsAtPath:@"class.json" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult){ NSLog(@"Success"); }failure:^(RKObjectRequestOperation *operation, NSError *error) {}]; </code></pre> <p>If you need anything else just let me know. And if you could help out I will be a very happy developer.</p> <p>Thank you,</p> <p>-DO</p> <h2><strong>EDIT</strong></h2> <p>This is what propertMappings returns</p> <pre><code>+ (NSDictionary *) propertyMappings{return @{@"id" : @"iD", @"name" : @"name", @"image_url" : @"image_url"};} </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload