Permalink
Browse files

Merge pull request #94 from protocool/master

[NEW] Per-entity custom base classes via `mogenerator.customBaseClass` entity userinfo key (overrides `--base-class-force`). ([Trevor Squires](#94))
  • Loading branch information...
2 parents 1e081a4 + 80669a4 commit 029b6537b22637a8f1ff7b609400adcb31e9824a @rentzsch committed Mar 9, 2012
Showing with 8 additions and 2 deletions.
  1. +1 −0 mogenerator.h
  2. +7 −2 mogenerator.m
View
1 mogenerator.h
@@ -23,6 +23,7 @@
@interface NSEntityDescription (customBaseClass)
- (BOOL)hasCustomSuperentity;
- (NSString*)customSuperentity;
+- (NSString*)forcedCustomBaseClass;
- (void)_processPredicate:(NSPredicate*)predicate_ bindings:(NSMutableArray*)bindings_;
- (NSArray*)prettyFetchRequests;
@end
View
9 mogenerator.m
@@ -67,17 +67,22 @@ - (BOOL)hasCustomSuperentity {
}
}
- (NSString*)customSuperentity {
- if(!gCustomBaseClassForced) {
+ NSString *forcedBaseClass = [self forcedCustomBaseClass];
+ if(!forcedBaseClass) {
NSEntityDescription *superentity = [self superentity];
if (superentity) {
return [superentity managedObjectClassName];
} else {
return gCustomBaseClass ? gCustomBaseClass : @"NSManagedObject";
}
} else {
- return gCustomBaseClassForced;
+ return forcedBaseClass;
}
}
+- (NSString*)forcedCustomBaseClass {
+ NSString* userInfoCustomBaseClass = [[self userInfo] objectForKey:@"mogenerator.customBaseClass"];
+ return userInfoCustomBaseClass ? userInfoCustomBaseClass : gCustomBaseClassForced;
+}
/** @TypeInfo NSAttributeDescription */
- (NSArray*)noninheritedAttributes {
NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]];

0 comments on commit 029b653

Please sign in to comment.