@FetchRequest in a class, SwiftUI

Hello

I was trying to use @FetchRequest in a class, but found it doesn't work, so I was wondering if there was a way to use something that works like @FetchRequest in a class?

Thank You!

Answered by DelawareMathGuy in 686685022

hi,

you can certainly do a fetch directly with core data; but if you expect your class object to find out about changes in Core Data and act like you had a @FetchRequest, you would want to use an NSFetchedResultsController in your object to see changes over time.

hope that helps, DMG

Accepted Answer

hi,

you can certainly do a fetch directly with core data; but if you expect your class object to find out about changes in Core Data and act like you had a @FetchRequest, you would want to use an NSFetchedResultsController in your object to see changes over time.

hope that helps, DMG

@FetchRequest in a class, SwiftUI
 
 
Q