Reputation: 1614
I want to know how to filter data while using a searchBar. Lets say I have 300 friend objects and I want to find a specific friend named "Rick" in my tableView. While searching, I would like to filter my friends every time a character is enter. So if I type in a R in search bar all names starting with r shows. Then when I type in an I it filters all names starting with RI and so on.
Upvotes: 0
Views: 570
Reputation: 23
One way of filtering core data fetches is by using predicates. You could do something like this:
let fetchPredicate: NSPredicate = NSPredicate(format: "whichever property you are fetching = %@", Your textfield.text)
fetchRequest.predicate = fetchPredicate
You may have to trick it a bit around to make it fit to your needs, but that is one way of sorting your fetches in core data.
Upvotes: 1