Skip to content

Commit

Permalink
- Return all properties in arrays sorted by property name.
Browse files Browse the repository at this point in the history
- This guarantees stable ordering on subsequent mogenerator runs.
  • Loading branch information
nikita-zhuk committed Jun 4, 2011
1 parent 7d458b1 commit 6145072
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

Expand Down

0 comments on commit 6145072

Please sign in to comment.