Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- Return all properties in arrays sorted by property name.

- This guarantees stable ordering on subsequent mogenerator runs.
  • Loading branch information...
commit 61450726028585633b93274269eb5c77c7b5c83e 1 parent 7d458b1
Nikita Zhuk authored June 04, 2011

Showing 1 changed file with 9 additions and 6 deletions. Show diff stats Hide diff stats

  1. 15  mogenerator.m
15  mogenerator.m
@@ -74,35 +74,38 @@ - (NSString*)customSuperentity {
74 74
 }
75 75
 /** @TypeInfo NSAttributeDescription */
76 76
 - (NSArray*)noninheritedAttributes {
  77
+	NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]];
77 78
 	NSEntityDescription *superentity = [self superentity];
78 79
 	if (superentity) {
79 80
 		NSMutableArray *result = [[[[self attributesByName] allValues] mutableCopy] autorelease];
80 81
 		[result removeObjectsInArray:[[superentity attributesByName] allValues]];
81  
-		return result;
  82
+		return [result sortedArrayUsingDescriptors:sortDescriptors];
82 83
 	} else {
83  
-		return [[self attributesByName] allValues];
  84
+		return [[[self attributesByName] allValues] sortedArrayUsingDescriptors:sortDescriptors];
84 85
 	}
85 86
 }
86 87
 /** @TypeInfo NSAttributeDescription */
87 88
 - (NSArray*)noninheritedRelationships {
  89
+	NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]];
88 90
 	NSEntityDescription *superentity = [self superentity];
89 91
 	if (superentity) {
90 92
 		NSMutableArray *result = [[[[self relationshipsByName] allValues] mutableCopy] autorelease];
91 93
 		[result removeObjectsInArray:[[superentity relationshipsByName] allValues]];
92  
-		return result;
  94
+		return [result sortedArrayUsingDescriptors:sortDescriptors];
93 95
 	} else {
94  
-		return [[self relationshipsByName] allValues];
  96
+		return [[[self relationshipsByName] allValues] sortedArrayUsingDescriptors:sortDescriptors];
95 97
 	}
96 98
 }
97 99
 /** @TypeInfo NSFetchedPropertyDescription */
98 100
 - (NSArray*)noninheritedFetchedProperties {
  101
+	NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]];
99 102
 	NSEntityDescription *superentity = [self superentity];
100 103
 	if (superentity) {
101 104
 		NSMutableArray *result = [[[[self fetchedPropertiesByName] allValues] mutableCopy] autorelease];
102 105
 		[result removeObjectsInArray:[[superentity fetchedPropertiesByName] allValues]];
103  
-		return result;
  106
+		return [result sortedArrayUsingDescriptors:sortDescriptors];
104 107
 	} else {
105  
-		return [[self fetchedPropertiesByName] allValues];
  108
+		return [[[self fetchedPropertiesByName] allValues]  sortedArrayUsingDescriptors:sortDescriptors];
106 109
 	}
107 110
 }
108 111
 

0 notes on commit 6145072

Please sign in to comment.
Something went wrong with that request. Please try again.