Skip to content

Commit

Permalink
Allow a forced custom base class to be specified in the Entity userInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
protocool committed Mar 8, 2012
1 parent 1e081a4 commit 80669a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions mogenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@interface NSEntityDescription (customBaseClass)
- (BOOL)hasCustomSuperentity;
- (NSString*)customSuperentity;
- (NSString*)forcedCustomBaseClass;
- (void)_processPredicate:(NSPredicate*)predicate_ bindings:(NSMutableArray*)bindings_;
- (NSArray*)prettyFetchRequests;
@end
Expand Down
9 changes: 7 additions & 2 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
Expand Down

0 comments on commit 80669a4

Please sign in to comment.