Did anyone come around a solution for filtering data ( CoreData ) by a day, using NSPredicateEditor ? The idea is to make it most convenient to the user. The standard solution would be to define 2 criteria for date :
- one for >= start of the day
- another one for <= end of the day.
One EditorRowTemplate should simply look like:
left expression = aDate (property of a Core Data entity )
rightexpression = Dates
Then, the app should convert the predicate to somewhat like:
"aDate >= '3.5.20210 00:00:00' AND aDate <= '3.5.20210 23:59:59'".
Of course, it should take the value from the date which the user has entered in the row template.
I thought, closures can be a way. So to say, creating the NSPredicate programmatically. But how to use it in NSExpression and grabbing the date from the input ?
The desired row template should look like this :
The row template can convert the predicate in
predicate(withSubpredicates:)
, no other overrides required. In IB the right expressions are Dates.