Case Insensitive Compare with Core Data and Swift
Swift 3 - 5.0 Syntax
let sortDescriptor = NSSortDescriptor(key: "KeyName", ascending: true, selector: #selector(NSString.caseInsensitiveCompare))
The selector is caseInsensitiveCompare:
, with the colon, and you can use it with Core Data.
The colon is there because the method (which is an instance method of NSString
) takes one argument (the string to compare with).
As list of sort selectors which can be used with Core Data and a SQLite store can be found in Persistent Store Types and Behaviors in the Core Data Programming Guide.