SwiftUI Dynamic Predicate for FetchRequest

  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:

struct AllUsers: View {

@State private var searchTerm: String = “”

var body: some View {

TextField(“first or last name”, text: $searchTerm) // this is the search box

listUsers(searchTerm: searchTerm) // FetchRequest is in this sub-view

} // end view

} // end struct

How this works




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Take a Snapshot of a UIIView iOS

iOS Developer: From Noob to Ninja in 30 days — Day 5, Three REAL use cases for Closures…

Re-thinking iOS Coordinators to Build Scalable Apps

From Native to Flutter, a developer story

Making an image into a circle or rounded iOS

Adding Test files to XCode project iOS

Pod Install Hook Up With Xcode IDE

Load Document files like .pfd,.txt,.doc etc

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Ho

Andrew Ho

More from Medium

Protecting your DAO with multi-signature wallets

SNXweave Weekly Recap

Juno — A community driven smart contract platform

Monthly Newsletter #03 | What Are Novas?!