I have usual SwiftUI view like this
struct MyView: View {
@FetchRequest var users: FetchedResults<User>
init() {
self._users = FetchRequest(
entity: User.entity(),
sortDescriptors: [
],
predicate: NSPredicate(format: "company.id == %@", companyId)
)
}
var body: some View {
List {
ForEach(Array(self.users.enumerated()), id: \.1.objectID) { (i, user) in
Text("\(user.name)")
}
}
}
But after locking screen/using home button and returning to app. Initially this view wake ups with empty NSManagedObjects, objects seems to be available there is correct users.count value, each object has its appropriate objectID. But other managed object properties are nil. Then sometimes I experience that in subsequent view refreshes it can (I think "fault" this object properties) fetch this properties and displays ok, or can stay with nil values and I have empty results on list or crash depending user.name is forced unwrap or not
user.name! or user.name ?? ""