Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add convenience methods involving the entity name to machine generated classes #9
Would you be so kind to add these convenience methods to the machine-generated classes? I know that I should be able to add these myself to the *.motemplate files but I fear that if I do that it'll break my code when I upgrade mogenerator.
2¢ : Such methods can be added as categories on NSManagedObject, which I for one have done. With the exact same method names, I believe. That would cause a conflict (which implementation gets used is undefined IIRC). I'm undecided if I'd find this change disagreeable. I guess I could remove them from my category, but then I'd no longer be able to use those methods on plain NSManagedObjects.
@rentzsch Sure. Here you go:
I hope the method names suits you.
On your additions to NSManagedObject, how do you pass the entity name strings? (the names you define in XCode data modeler). The last time I checked, you'll need either
a) a live instance of NSManagedObject and then call [-managedObjectClassName] (note that this is a non-static method.
b) Type in the entity name yourself (which you may need to update in the Objective-C source file whenever you change the entity name in XCode Data Modeler.
My suggestion is essentially going with option b) but the entity name is "typed in" by mogenerator.
It would be nice if that
They might also be defined as "constants", e.g. in the generated _MyManagedObject.h:
and in _MyManagedObject.m:
But I think the first alternative is preferable.