Created
April 14, 2012 10:38
-
-
Save hajipy/2383469 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// managedObjectModelからFetchedPropertyを検索し、ソート条件を追加 | |
// NSPersistentStoreCoordinatorを作成する前に行うこと! | |
for (NSEntityDescription* entity in [managedObjectModel entities]) { | |
for (NSPropertyDescription* property in [entity properties]) { | |
if ([property isKindOfClass:[NSFetchedPropertyDescription class]]) { | |
NSFetchedPropertyDescription* fetchedProperty = (NSFetchedPropertyDescription*) property; | |
NSFetchRequest* fetchRequest = [fetchedProperty fetchRequest]; | |
if ([[[[fetchRequest entity] propertiesByName] allKeys] containsObject:@"twId"]) { | |
NSSortDescriptor* sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"twId" ascending:NO] autorelease]; | |
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]]; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment