The problem I am facing is the following:
I have a UITableView that I pass with data from NSFetchedResultsController , which fetches about 6,000 rows from the main data. fetchBatchSize of NSFetchRequest set to 20, and if I don't use any NSSortDescriptor , the fetch is fast enough to not block the UI thread.
However, I need to display those strings sorted alphabetically for which I use the following NSSortDescriptor:
[[[NSSortDescriptor alloc] initWithKey:@"optionText" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)] autorelease];
So when the situation changes, the selection operation now takes about 3 seconds, because 6,000 rows are sorted. Obviously, during these seconds, the user interface is blocked and the user experience is terrible.
I know that I can make a selection in the background thread and then go to the object identifiers in the main thread, but in this case, how can I use the NSFetchedResultsController in the main thread (I also use it to observe data changes)?
I also have an indexed attribute by which I sort, but which only optimizes the search and does not perform sorting.
Any ideas would be greatly appreciated, thanks!
sorting background core-data nsfetchedresultscontroller
monchote
source share