Using RestKit and CoreData with Swift
RestKit offers functionality for directly binding JSON to NSManagedObject instances. You use the following line of code to initialize the RKEntityMapping object:
var classMapping :RKEntityMapping = RKEntityMapping(forEntityForName:"className",inManagedObjectStore:managedObjectStore)
This leads to the following error: The application terminated due to the uncaught exception "NSInternalInconsistencyException", reason: "Unable to initialize entity mapping for object with nil managed object class: Got nil class for managed object class name" className ". Maybe you forgot to add class files to your goal?
The error occurs because of this line in the RestKit API:
Class objectClass = NSClassFromString([entity managedObjectClassName]);
Decision:
If your NSManagedObject class is written in Swift, you must add the following code before declaring the class:
@objc(className) class className { ... }
Hope this helps!
mapping swift core-data restkit
Eddz
source share