3lvis/DATASource

How to change predicate on fetchrequest?

petkrein opened this issue · 3 comments

Hey 3lvis,

i need to change the predicate when text change called on e.g. SearchBar. But there is no way to access the fetchedResultController to update the predicates!

What i need is something like this:

let frc = myDataSource.fetchedResultsController
frc.fetchRequest.predicate = NSPredicate(format: "firstname CONTAINS[cd] %@", searchString)
try! frc.performFetch()
        
tableView.reloadData()
3lvis commented

Hi Peter! I hope you're having a nice weekend. I've gotten this question before so I'll make sure to update the README if I'm right in understanding what you want.

You can do

dataSource.predicate = myNewPredicate

And everything should work. Let me know if this doesn't solve your issue :)

Hi 3lvis,

you are right, the predicate feature was added in Version 6.1.7.
(my pod Version 6.1.5).

Thank you and that solves my issue.

3lvis commented

You're welcome, have a great week :)