From 80669a41adf993dcee274d562c59ce36c97b1171 Mon Sep 17 00:00:00 2001 From: Trevor Squires Date: Thu, 8 Mar 2012 14:41:06 -0800 Subject: [PATCH] Allow a forced custom base class to be specified in the Entity userInfo --- mogenerator.h | 1 + mogenerator.m | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mogenerator.h b/mogenerator.h index d1f50787..e783e324 100644 --- a/mogenerator.h +++ b/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 diff --git a/mogenerator.m b/mogenerator.m index 38f00b64..f2861849 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -67,7 +67,8 @@ - (BOOL)hasCustomSuperentity { } } - (NSString*)customSuperentity { - if(!gCustomBaseClassForced) { + NSString *forcedBaseClass = [self forcedCustomBaseClass]; + if(!forcedBaseClass) { NSEntityDescription *superentity = [self superentity]; if (superentity) { return [superentity managedObjectClassName]; @@ -75,9 +76,13 @@ - (NSString*)customSuperentity { 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]];