CoreData: transient property and localizedCaseInsensitiveCompare
In coredata, i have a transient property to use has sections. The transient property code is here:
- (NSString *) firstLetter_transient {
[self willAccessValueForKey:@"firstLetter_transient"];
NSString *initial = [[[self memberName] substringToIndex:1] uppercaseString];
[self didAccessValueForKey:@"firstLetter_transient"];
return initial;
}
When I apply this, in Portuguese language, I get, for example "Á" has th开发者_JS百科e first letter.
Question Nr 1: how can I put "Á" in the "A" section? I have an error with this:
"The operation couldn’t be completed. (Cocoa error 134060.)"
Question Nr 2: when it comes to numbers, how can I affect the numbers to section named "#"? Now, the number 1 creates a section "1", and so on.
Thanks all,
RL
You should use UILocalizedIndexedCollation for doing sorting and categorizing entries into sections. The code for implementing this is in the question NSFetchedResultsController v.s. UILocalizedIndexedCollation
The UILocalizedIndexedCollation was built to be able to on a per-language basis categorize words based on the current language settings. Á and à will be put in section A.
精彩评论