How do I update Attachments to a VisionOS Entity when a referenced CoreData Entity is updated?
I am getting close!
So far, I can get UI updates automatically in a SwiftUI View when a CoreData Entity is updated. For example, the following list will update automatically when "name" is updated on a StudyParticipantEntity after the view was created, as expected:
@FetchRequest(fetchRequest: StudyParticipantEntity.fetch(), animation: .bouncy) var studyParticipants:FetchedResults<StudyParticipantEntity>
List(studyParticipants, id: \.self){ studyParticipant in
ZStack{
Text(studyParticipant.name!)
}
}
However, I DO NOT get automatic updates to UI in attachments to the model entity that reference the same core data entity:
Creating the attachment, passing in the same core data entity studyParticipantEntity:
let attachmentRightLegView = AttachmentFollowedRightLeg(
name: followedRunTimeComponent.attachmentTag,
studyParticipantEntity: theStudyParticipantEntity
)
.tag(attachmentTagRightLeg)
Important: I DO get automatic updates in the attachment if I instead reference a typical value type in the viewModel.
Any suggestions? Thanks much!