SwiftUI Dynamic Predicate for FetchRequest

I Learn faster by Example

A View cannot change its own FetchRequest after the view has been created. What if we want to modify the query string and update the display based on user input?

This SwiftUI limitation causes a small challenge when coding search boxes and other dynamic queries. The example below shows how this can be done:

  1. A View cannot change its own FetchRequest, but it can change the FetchRequest of one of its sub-Views. Thus, use a sub-View to generate the FetchRequest: