Created
April 8, 2014 11:26
-
-
Save g-1/10111708 to your computer and use it in GitHub Desktop.
NSFetchedResultControllerでのセクションごとのソート順がUITableViewControllerで反映されない場合の対処法 ref: http://qiita.com/g-1/items/c97685fc98ff7e499c75
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
NSSortDescriptor* sortDescriptorWithName = [[NSSortDescriptor alloc] initWithKey:@"name" | |
ascending:YES]; | |
NSArray* aSortDescriptor = @[sortDescriptorWithName]; | |
[fetchRequest setSortDescriptors:aSortDescriptor]; | |
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"status >= 0"]; | |
[fetchRequest setPredicate:predicate]; | |
NSFetchedResultsController* fetchedResultsController = | |
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest | |
managedObjectContext:self.managedObjectContext | |
sectionNameKeyPath:@"status" | |
cacheName:@"Master"]; |
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
NSSortDescriptor* sortDescriptorWithName = [[NSSortDescriptor alloc] initWithKey:@"name" | |
ascending:YES]; | |
NSSortDescriptor* sortDescriptorWithStatus = [[NSSortDescriptor alloc] initWithKey:@"status" | |
ascending:YES]; | |
NSArray* aSortDescriptor = @[sortDescriptorWithStatus,sortDescriptorWithName]; | |
[fetchRequest setSortDescriptors:aSortDescriptor]; | |
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"status >= 0"]; | |
[fetchRequest setPredicate:predicate]; | |
NSFetchedResultsController* fetchedResultsController = | |
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest | |
managedObjectContext:self.managedObjectContext | |
sectionNameKeyPath:@"status" | |
cacheName:@"Master"]; |
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
NSArray* aSortDescriptor = @[sortDescriptorWithName, sortDescriptorWithStatus]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment