diff --git a/mogenerator.m b/mogenerator.m index 15ff65c2..ef890b4d 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -10,6 +10,25 @@ NSString *gCustomBaseClass; +@interface NSEntityDescription (fetchedPropertiesAdditions) +- (NSDictionary *)fetchedPropertiesByName; +@end + +@implementation NSEntityDescription (fetchedPropertiesAdditions) +- (NSDictionary *)fetchedPropertiesByName +{ + NSMutableDictionary *fetchedPropertiesByName = [NSMutableDictionary dictionary]; + + for (NSPropertyDescription *property in [self properties]) + { + if([property isKindOfClass:[NSFetchedPropertyDescription class]]) + [fetchedPropertiesByName setObject:property forKey:[property name]]; + } + + return fetchedPropertiesByName; +} +@end + @implementation NSManagedObjectModel (entitiesWithACustomSubclassVerbose) - (NSArray*)entitiesWithACustomSubclassVerbose:(BOOL)verbose_ { NSMutableArray *result = [NSMutableArray array]; @@ -76,6 +95,17 @@ - (NSArray*)noninheritedRelationships { return [[self relationshipsByName] allValues]; } } +/** @TypeInfo NSFetchedPropertyDescription */ +- (NSArray*)noninheritedFetchedProperties { + NSEntityDescription *superentity = [self superentity]; + if (superentity) { + NSMutableArray *result = [[[[self fetchedPropertiesByName] allValues] mutableCopy] autorelease]; + [result removeObjectsInArray:[[superentity fetchedPropertiesByName] allValues]]; + return result; + } else { + return [[self fetchedPropertiesByName] allValues]; + } +} #pragma mark Fetch Request support