From 61450726028585633b93274269eb5c77c7b5c83e Mon Sep 17 00:00:00 2001 From: Nikita Zhuk Date: Sat, 4 Jun 2011 12:18:06 +0300 Subject: [PATCH] - Return all properties in arrays sorted by property name. - This guarantees stable ordering on subsequent mogenerator runs. --- mogenerator.m | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mogenerator.m b/mogenerator.m index 0bb789b9..34722839 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -74,35 +74,38 @@ - (NSString*)customSuperentity { } /** @TypeInfo NSAttributeDescription */ - (NSArray*)noninheritedAttributes { + NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]; NSEntityDescription *superentity = [self superentity]; if (superentity) { NSMutableArray *result = [[[[self attributesByName] allValues] mutableCopy] autorelease]; [result removeObjectsInArray:[[superentity attributesByName] allValues]]; - return result; + return [result sortedArrayUsingDescriptors:sortDescriptors]; } else { - return [[self attributesByName] allValues]; + return [[[self attributesByName] allValues] sortedArrayUsingDescriptors:sortDescriptors]; } } /** @TypeInfo NSAttributeDescription */ - (NSArray*)noninheritedRelationships { + NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]; NSEntityDescription *superentity = [self superentity]; if (superentity) { NSMutableArray *result = [[[[self relationshipsByName] allValues] mutableCopy] autorelease]; [result removeObjectsInArray:[[superentity relationshipsByName] allValues]]; - return result; + return [result sortedArrayUsingDescriptors:sortDescriptors]; } else { - return [[self relationshipsByName] allValues]; + return [[[self relationshipsByName] allValues] sortedArrayUsingDescriptors:sortDescriptors]; } } /** @TypeInfo NSFetchedPropertyDescription */ - (NSArray*)noninheritedFetchedProperties { + NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]; NSEntityDescription *superentity = [self superentity]; if (superentity) { NSMutableArray *result = [[[[self fetchedPropertiesByName] allValues] mutableCopy] autorelease]; [result removeObjectsInArray:[[superentity fetchedPropertiesByName] allValues]]; - return result; + return [result sortedArrayUsingDescriptors:sortDescriptors]; } else { - return [[self fetchedPropertiesByName] allValues]; + return [[[self fetchedPropertiesByName] allValues] sortedArrayUsingDescriptors:sortDescriptors]; } }