How to Use @FetchRequest in SwiftUI

1 · Andrew Bancroft · Aug. 3, 2019, 4:18 p.m.
Once you’ve passed an NSManagedObjectContext instance to your SwiftUI View, you’ll need to pull data out of your Core Data persistent store with a fetch request. First Things First The remainder of this how-to assumes that you’ve already got a way to initialize the Core Data stack. Ticking the ‘Use Core Data’ checkbox when you start a new app will place some boilerplate code in AppDelegate. @Environment(\.managedobjectcontext) must be assigned before the View is initialized for @FetchRequest to...