Case insensitive Comparison with master data and speed

The following code does not work:

let sortDescriptor = NSSortDescriptor(key: "name", ascending: true, selector:"caseInsensitiveCompare")

And gives the following error: "NSInvalidArgumentException", reason: "unsupported selector NSSortDescriptor: caseInsensitiveCompare"

It seemed to work fine in Objective-C. Any ideas on why this might be?

Edit: Looks like it might not be possible with Core Data / SQLite. In this case, it is best to get an array and sort it in code after?

+4
source share
2 answers

A caseInsensitiveCompare:colon selector , and you can use it with Core Data.

, ( NSString) ( ).

, Core Data SQLite .

+6
    let sortDescriptor = NSSortDescriptor(key: "KeyName", ascending: true, selector: #selector(NSString.caseInsensitiveCompare))
+25

Source: https://habr.com/ru/post/1627069/


All Articles