Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow per-entity definition of custom base class #94

Merged
merged 1 commit into from Mar 9, 2012
Jump to file or symbol
Failed to load files and symbols.
+8 −2
Split
View
@@ -23,6 +23,7 @@
@interface NSEntityDescription (customBaseClass)
- (BOOL)hasCustomSuperentity;
- (NSString*)customSuperentity;
+- (NSString*)forcedCustomBaseClass;
- (void)_processPredicate:(NSPredicate*)predicate_ bindings:(NSMutableArray*)bindings_;
- (NSArray*)prettyFetchRequests;
@end
View
@@ -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]];