I came across this discussion stating that it’s not possible to have a dynamic filter in ObservedResult
property wrapper. It suggests to filter in the view body instead.
But I was able to update the filter of the ObservedResult
like this:
struct SomeView: View {
@ObservedResults(SomeType.self, configuration: config) var objects
func setFilter(_ filter: NSPredicate) {
_objects.filter = filter
}
var body: some View { ... }
}
After reading the code it seems that ObservedResults
was designed to make it possible to update the parameters, so I don’t see why this wouldn’t be the correct solution? Did I miss something?