In a core data fetch request I want to sort the result case insensitive.
So I coded:
NSSortDescriptor *sortDescriptor =
[[NSSortDescriptor alloc] initWithKey:@"name"
ascending:YES
comparator:^(id s1, id s2)
{
return [s1 localizedCaseInsensitiveCompare:s2];
}];
but unfortunately the result is still:
B U a c y z.
But the Block seems to be ok, because if I sort the result with that code:
NSMutableArray* names = ......
[names sortUsingComparator:^(id s1, id s2)
{
return [s1 localizedCaseInsensitiveCompare:s2];
}];
than the result is:
a B c U y z.
Where is my fault?
I’ve found a solution not with Block – but with selector:
if “name” is a string-attribute of a core data Entity it works well.