I am using Xcode 13.4.1 and Swift 5. I have a searchBar delegate in which I am trying to search for the string inside the searchBar from a core data entity called Item. I am getting the following error:
[error] error: SQLCore dispatchRequest: exception handling request: <NSSQLFetchRequestContext: 0x60000311df80> , unimplemented SQL generation for predicate : (title CONTAINS[cd] "Aib") with userInfo of (null)
There are not many answers available online and the ones that are available are very old ones in Objective-C and has not worked so far for me. How can I do this with the latest version of Swift.
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
let request: NSFetchRequest<Item> = Item.fetchRequest()
request.predicate = NSPredicate(format: "title CONTAINS[cd] %@", searchBar.text!)
request.sortDescriptors = [NSSortDescriptor(key: "title", ascending: true)]
do {
itemArray = try context.fetch(request)
toDoListTableView.reloadData()
}
catch {
print("search error \(error)")
}
}