How are you accessing this data in your SwiftUI View?
You can power a SwiftUI view from a fetch request directly.
Example:
struct FavoriteQuotesView: View {
@FetchRequest(entity: Quote.entity(), sortDescriptors: [], predicate: NSPredicate(format: "isFavorited == true")) var quotes: FetchedResults<Quote>
var body: some View {
List {
ForEach(quotes) { quote in
Text(quote.text)
}
}
}
}
As data is updated that affects that query, it will update your SwiftUI view.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…