Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSFetchedResultsController ERROR: The fetched object at index 248 has an out of order section name

trying the solution here: https://stackoverflow.com/questions/1741093?tab=newest#tab-top

I'm using a transient property and the category solution and it seems to be working right up until the index char starts to wrap around to the A's again, not sure why it's doing that, just logging what the category/transient getter is returning for uppercaseFirstLetterOfName.

I'm sorting using the name property and then setting sectionNameKeyPath on the fetchRequest to uppercaseFirstLetterOfName.

The full error is: NSFetchedResultsController ERROR: The fetched object at index 248 has an out of order section name 'Y. Objects must be sorted by section name'

Any ideas where I might have gone wrong or how to even track down the problem?

like image 408
Cricketgeek Avatar asked Jun 28 '10 18:06

Cricketgeek


1 Answers

I found the problem. Because the sort was producing caps and lower case dups I suppose but the indextitles weren't I got that out of order index/section name:

just added this to the fetch selector:@selector(caseInsensitiveCompare:)

so it is now: NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES selector:@selector(caseInsensitiveCompare:)];

and works cracker jack!

like image 92
Cricketgeek Avatar answered Nov 02 '22 05:11

Cricketgeek