Convert NSFetchedResultsController result to NSArray

I am executing an NSFetchedResultsController to populate a View table with a fast alphabet index on the side. This works fine, but I would like to implement a search function made by another developer, and this search function is needed to enter the base NSArray (this is used to work with the result of a simple NSFetchRequest). So how can this conversion be done?

here is the request part:

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[NSEntityDescription entityForName:@"domaine" inManagedObjectContext:managedObjectContext]];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"nom_court" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
[sortDescriptors release];
[sortDescriptor release];
fetchedResultsController = [[NSFetchedResultsController alloc]initWithFetchRequest:fetchRequest 
                                                managedObjectContext:managedObjectContext sectionNameKeyPath:@"nom_court" cacheName:@"root"];
[fetchRequest release];
NSError *error;

//BOOL success = [controller performFetch:&error];
[fetchedResultsController performFetch:&error];

thank

+3
source share
1 answer

Call NSArray *fetchedObjects = [fetchedResultsController fetchedObjects];after method callperformFetch:

+18
source

Source: https://habr.com/ru/post/1777044/


All Articles