views:

29

answers:

2

I'm trying to make Core Data objects inherit from my own custom class rather than NSManagedObject. I started using Mogenerator and noticed that it has a --base-class arugument which does exactly what I want.

The problem is that by default it doesn't use this parameter, and so every time I save my data model file, it sets the inherited class to NSManagedObject. Is there any way to add this additional parameter to the script so that it works as I want it to every time I save the .xcdatamodel file?

If not, is there any other way I can easily run this command from Xcode? I was thinking about creating it as a User Script. The problem is that I don't want it hardcoded to this project's files. This is an example of the command line I need to run:

mogenerator -m MyProject.xcdatamodeld/MyProject.xcdatamodel -O Classes --base-class MyManagedObject

Ideally, it should find the .xcdatamodel file of the current project. As I have no experience in mac development, I would appreciate it if you could point me in the right direction and tell me which commands will be the most useful to me if do indeed make this script myself.

A: 

I suspect for this question, filing a bug on github will get Wolf's attention. I am not sure he goes to this site.

Marcus S. Zarra
+1  A: 

From the Mogen readme

Xmo'd: model comments that start with -- are passed as args to mogenerator. This allows accessing command-line options such as --base-class. (David LeBer)

In Xcode, get info on the actual .xcdatamodel file and in the Comments tab enter xmod and then the args. That should customize Mogen as you wish.

TechZen