Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] rentzsch#42 broken #import NSManagedObject.h codegen
Browse files Browse the repository at this point in the history
rentzsch committed Feb 27, 2013

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 786ddae commit 0653ad6
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions mogenerator.h
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
@end

@interface NSEntityDescription (customBaseClass)
- (BOOL)hasCustomClass;
- (BOOL)hasSuperentity;
- (BOOL)hasCustomSuperentity;
- (NSString*)customSuperentity;
18 changes: 14 additions & 4 deletions mogenerator.m
Original file line number Diff line number Diff line change
@@ -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];
}
}

@@ -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) {
@@ -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) {
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 0653ad6

Please sign in to comment.