I am using core data with NSFetchedResultController
. In this case, I have an n
number of user groups and a user can select a particular group or select all group
. So manually I added All group
title, static ID
and relevant content to the database.
NSFetchRequest <IRSUserAssetGroup *> *fetchRequest = [NSFetchRequest fetchRequestWithEntityName: [IRSUserAssetGroup entityName]];
NSSortDescriptor *nameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey: NSStringFromSelector(@selector(assetGroupName))
ascending: YES
selector: @selector(localizedCaseInsensitiveCompare:)];
[fetchRequest setSortDescriptors: @[nameSortDescriptor]];
[fetchRequest setFetchBatchSize: 4];
NSManagedObjectContext *mainContext = [[IRSCoreDataManager sharedManager] managedObjectContext];
NSFetchedResultsController <IRSUserAssetGroup *> *fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest
managedObjectContext: mainContext
sectionNameKeyPath: nil
cacheName: nil];
NSError *fetchError = nil;
if (![fetchedResultsController performFetch: &fetchError])
FCALog(@"fetch error: %@", fetchError);
[self setUserAssetGroupFetchedResultsController: fetchedResultsController];
This is my FRC
code. I am using sort by name. Some group name has start with the number. Because of this All group
not place in first place.
Is that possible All group
place always top on sort?
Extra: I am using table view with search option
Example: @[@1, @5, @"text", @"aaaaaaa", @"All group"]
. Here All group
show always on top of the list. How can I sort like that.
Output: @[@"All group", @1, @5, @"aaaaaaa", @"text"]