CoreData:瞬态属性和 localizedCaseInsensitiveCompare
在 coredata 中,我有一个瞬态属性可以使用 has 部分。瞬态属性代码在这里:
- (NSString *) firstLetter_transient {
[self willAccessValueForKey:@"firstLetter_transient"];
NSString *initial = [[[self memberName] substringToIndex:1] uppercaseString];
[self didAccessValueForKey:@"firstLetter_transient"];
return initial;
}
当我在葡萄牙语中应用此代码时,我得到,例如“Á”有第一个字母。
问题 1:如何将“Á”放入“A”部分?我遇到一个错误:
“操作无法完成。(Cocoa 错误 134060。)”
问题 2:当涉及到数字时,如何影响名为“#”的部分的数字?现在,数字 1 创建一个部分“1”,依此类推。
谢谢大家,
RL
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 the 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用 UILocalizedIndexedCollation 对条目进行排序和分类。实现此功能的代码位于问题 NSFetchedResultsController vs UILocalizedIndexedCollation
UILocalizedIndexedCollation 的构建是为了能够在每个语言基础根据当前语言设置对单词进行分类。 Á 和 à 将放在 A 部分。
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.