I just began coding and I've chosen swift. I have a CoreData database and I use a predicate to display parts of it. It works fine to find a complete expression. What can I do to search in the datafield Strasse.name just a part of a string like "*way". Here is my code:
let myFetschRequest = NSFetchRequest(entityName: "Strasse")
var filter1 = "searchword"
var filter2 = "searchword"
let predicate1 = NSPredicate(format: "name = %@", filter1)
let predicate2 = NSPredicate(format: "art = %@", filter2)
var compound = NSCompoundPredicate.andPredicateWithSubpredicates([predicate1,predicate2])
myFetschRequest.predicate = compound
let sortDescriptor1 = NSSortDescriptor(key: "name", ascending: true)
let sortDescriptor2 = NSSortDescriptor(key: "bereich", ascending: true)
myFetschRequest.sortDescriptors = [sortDescriptor1,sortDescriptor2]
daten = context!.executeFetchRequest(myFetschRequest, error: nil) as! [Strasse]
tableView.reloadData()
Probably something like:
Just googled it real fast. Will test it later if it works.
Tested and working.