Skip to content

Commit

Permalink
[FIX] rentzsch#42 broken #import NSManagedObject.h codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
rentzsch committed Feb 27, 2013
1 parent dfe1e4b commit 3e60748
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions mogenerator.h
Expand Up @@ -19,6 +19,7 @@
@end

@interface NSEntityDescription (customBaseClass)
- (BOOL)hasCustomClass;
- (BOOL)hasSuperentity;
- (BOOL)hasCustomSuperentity;
- (NSString*)customSuperentity;
Expand Down
18 changes: 14 additions & 4 deletions mogenerator.m
Expand Up @@ -54,13 +54,13 @@ - (NSArray*)entitiesWithACustomSubclassInConfiguration:(NSString*)configuration_
nsenumerate (allEntities, NSEntityDescription, entity) {
NSString *entityClassName = [entity managedObjectClassName];

if ([entityClassName isEqualToString:@"NSManagedObject"] || [entityClassName isEqualToString:@""] || [entityClassName isEqualToString:gCustomBaseClass]){
if ([entity hasCustomClass]){
[result addObject:entity];
} else {
if (verbose_) {
ddprintf(@"skipping entity %@ (%@) because it doesn't use a custom subclass.\n",
entity.name, entityClassName);
}
} else {
[result addObject:entity];
}
}

Expand All @@ -77,6 +77,15 @@ - (BOOL)hasCustomBaseCaseImport {
- (NSString*)baseClassImport {
return gCustomBaseClassImport;
}

- (BOOL)hasCustomClass {
NSString *entityClassName = [self managedObjectClassName];
BOOL result = !([entityClassName isEqualToString:@"NSManagedObject"]
|| [entityClassName isEqualToString:@""]
|| [entityClassName isEqualToString:gCustomBaseClass]);
return result;
}

- (BOOL)hasSuperentity {
NSEntityDescription *superentity = [self superentity];
if (superentity) {
Expand All @@ -90,14 +99,15 @@ - (BOOL)hasCustomSuperentity {
if (!forcedBaseClass) {
NSEntityDescription *superentity = [self superentity];
if (superentity) {
return YES;
return [superentity hasCustomClass] ? YES : NO;
} else {
return gCustomBaseClass ? YES : NO;
}
} else {
return YES;
}
}

- (NSString*)customSuperentity {
NSString *forcedBaseClass = [self forcedCustomBaseClass];
if (!forcedBaseClass) {
Expand Down
Binary file modified test/test.xcdatamodel/elements
Binary file not shown.
Binary file modified test/test.xcdatamodel/layout
Binary file not shown.

0 comments on commit 3e60748

Please sign in to comment.