mogenerator creates invalid files for an entity with no class #105

Closed
mmower opened this Issue Apr 17, 2012 · 4 comments

Comments

Projects
None yet
3 participants

mmower commented Apr 17, 2012

I have an entity that I do not want to generate a managed object subclass for so I leave Class blank.

I'd hoped that mogenerator would ignore this entity but, instead it generates files:

.h
.m
_.h
_.m

which I then have to delete. I suppose I could just create a class and ignore it but I'd really prefer either an option to exclude this entity or (preferably) for mogenerator to ignore entities with no class defined.

Owner

rentzsch commented Apr 17, 2012

Instead of leaving Class field blank, try setting it to NSManagedObject (that's what Xcode's Data Modeler sets it to for new entities sans custom classes).

mmower commented Apr 17, 2012

When I said "blank" perhaps I was misstating. What I mean is that it's blank, ergo it takes the default value of NSManagedObject (that's what I see in the field).

Owner

rentzsch commented Apr 17, 2012

Hmm, that should work. mogenerator's Test Mule subproject has a an entity without a custom class just to test that (EntitySansCustomClass in https://github.com/rentzsch/mogenerator/tree/master/mogeneratorTestMule/mogeneratorTestMule_DataModel.xcdatamodel).

Do you have the same problem with Test Mule's datamodel?

Contributor

mattbauch commented Oct 8, 2012

Just had the same issue. When you delete the class from the Class field Xcode shows the grayish class name NSManagedObject.
However, the entity definition in the xcdatamodel contents actually looks like this:

<entity name="Client" representedClassName="" parentEntity="CoreDataObject" syncable="YES">

Notice that it doesn't have a representedClassName.
Putting NSManagedObject into the class field fixes this, the entity definition then looks like this, which does not produce _.h, _.m, .h and .m

<entity name="Client" representedClassName="NSManagedObject" parentEntity="CoreDataObject" syncable="YES">

Since representedClassName="" seems to be the new default (at least for Xcode 4.5), mogenerator should handle this correctly.

@rentzsch rentzsch closed this Oct 8, 2012

ddrccw pushed a commit to ddrccw/mogenerator that referenced this issue Jan 20, 2014

Matthias Bauch
fix for #105 - If the class name of an entity is "" (i.e. empty strin…
…g) it should be considered to not have a custom subclass. Recent versions of Xcode use the empty string as default class for entities.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment