CoreData localized sorting

98 views Asked by At

I need to sort data in CoreData entity containing special national characters. I have NSSortDescriptor as follows

let sorting = [NSSortDescriptor(keyPath: \Books.bokName, ascending: true)]
    

and found hint here iPhone CoreData - How to fetch managed objects, and sorting them ignoring case? Unfortunately it seems that newer vesrion of Swift included in XCode 12.3 doesn`t support selector parameter anymore. What other options I have?

1

There are 1 answers

0
Dawy On BEST ANSWER

Well, I realized that I have to use

NSSortDescriptor(key: "bokName", ascending: true, selector: #selector(NSString.localizedStandardCompare))

instead of init with keyPath.