gonzalezreal / Groot

From JSON to Core Data and back.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not locate the entity for \(className) even though it exists

mariusschoenefeld opened this issue · comments

I installed Groot via cocoapods and using xcode 9.3, swift 4.

When I Call:

let context = NSManagedObjectContext.mr_default()
let _: [MObject] = try objects(fromJSONArray: correctedJSON, inContext: context)

It throws the fatalError I can't explain to my self why. this object exists. Any ideas?

Hi @mariusschoenefeld. Is there any message with the fatalError? Without more context, I can only guess that MObject does not have a corresponding entity in the Core Data model.

commented

it is happening the same to me. When we get the let className = String(reflecting: self) the class name has Module.Entity and the entities only shows Entity

Yes, I'm experiencing the same issue at: let className = String(reflecting: self)

Yeah, it's a real issue...see this PR: #94

Hi all,

Please make sure that the module of the class is properly identified in the model:

screenshot 2018-12-12 at 09 23 27

In this example, taken from Groot unit tests, the model and the class are in the same module. If your case is different, you will need to be explicit about the module in which the class is implemented.

In case you don't control the model (ie. it is in a Cocoapod like specified in #94) you will need to discuss it with the author of that model.