I've been pulling my hair for the last few hours trying to figure out why insertNewObjectForEntityForName
is returning NSManagedObject
even though I'm trying to insert an entity of my own type.
Things I have checked a thousand times:
What are the possible reasons why this could be happening? I don't know where to look from here, and google didn't help much :(
EDIT (RESOLVED):
This had to do with versioning... I removed the data model and recreated it again, and everything started working, before there were a few versions that were previously used... sigh sometimes asking a question gives an idea of how to find a solution
I'm still confused of why that was happening, even though it's solved now
I ended up in a similar situation with a different solution. Through a series of unfortunate events (a namespace clash forced changing one of my entities) I ended up with a custom entity that had its Class set to the default of NSManagedObject in the data model rather than the proper custom subclass.
So before you go through the hassle of deleting your entire data model and rebuilding it (as I just did, thank god for git branching), just check to make sure your Class is still set properly.
I had this happen as well but it wasn't a corrupt model it was actual a typo in my entity definition in the model file.
Basically the entities and attributes were all correct but the "ClassName" for my entity had a typo. This cause Core Data to have enough info to actually read and write the entity but it was not able to instantiate the class (since it didn't actually exist with the name I had mistyped)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With