Search code examples
iosobjective-ccore-datamagicalrecordmogenerator

CoreData, Magical Record and mogenerator


I've just installed mogenerator to create the Managed Objects in my project.

I was working without mogenerator before.

I'm also using MagicalRecord.

I have an entity Message and I am trying to run the line...

return [Message countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"user == 123"]];

but I'm getting an unrecognized selector error on this line.

If I change it to...

return [_Message countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"user == 123"]];

It works fine. But the stupid thing is that I do this same function a couple of lines later with a different predicate and it works fine without the fix. I have tried without the predicate but get the same result.

EDIT

I just tried commenting this line out and putting...

return 0;

Now I get the unrecognized selector on the second use of this line. It's almost like I have to "initialise" the CoreData by calling it on _Message first?!?!

Any ideas?

EDIT 2

I'm also getting this when trying to run...

[Message createEntity];

Same unrecognised selector. This is very annoying if it's going to do this to all my Core Data stuff.


Solution

  • I don't know 100% that this was the answer but when I ran the project using AppCode in the iPhone simulator I saw an odd debug message that said the class Message was implemented twice.

    It must have been implemented in another framework I was using or something.

    When I changed the name of the core data entity back to something more unique it worked fine.

    I'm surprised this compiled at all TBH.