My app is using a Realm database to store a number of items. With a SearchBar, I search (case insensitive) for an item that may already be stored in the database (and if not, it will be added). The item names often contain one of the swedish characters and my problem is that when searching for a swedish character (å, ä or ö), the filter passes "a" or "o" as well, i.e. a search for "ä" results in a/A, å/Å and ä/Ä.
extension ItemsVC: UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController) {
if isFiltering() {
let predicate = NSPredicate(format: "name CONTAINS[cd] %@ AND NONE owners.name == %@", searchController.searchBar.text!, (category?.name)!)
items = realm.objects(Item.self).filter(predicate).sorted(byKeyPath: "name", ascending: true)
tableView.reloadData()
}
}
}