iPhone CoreData - How to fetch managed objects, and sorting them ignoring case?

前端 未结 4 470
我寻月下人不归
我寻月下人不归 2020-12-24 12:23

Does anyone know how to fetch some results sorting them alphabetically but ignoring case?

4条回答
  •  难免孤独
    2020-12-24 12:31

    If the app is localized in several languages, please consider using the localizedCaseInsensitiveCompare: selector instead of caseInsensitiveCompare. It will have the effect to avoid the letter 'é' to be after the letter 'e'.

    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
    

提交回复
热议问题