I'm not doing asynchronously.
safeAddExercice() is call from .onTapGesture() and just passing true to state property linked to .sheet().
Post
Replies
Boosts
Views
Activity
After spending a long time trying to understand the behavior and using all my knowledge of SwiftUI, CoreData and Combine, I finally "fix" by adding id to my ForEach like this :
ForEach(training.exerciceHistories.array as! [ExerciceHistory], id: \.self) {
exerciceHistory in
		ExerciceHistoryRow(exerciceHistory: exerciceHistory)
		.padding(.bottom, 10)
}.id(UUID())
Already try to force with self.training.objectWillChange.send(), not working. I struggled a lot with this problem and I'm very confused about what I missed.
Using generated accessor is not working too.
I just run this :
struct Item {
var name = ""
}
var array1 = [Item(name: "1a"), Item(name: "1b")]
var array2 = [Item(name: "2a"), Item(name: "2b")]
struct MyForm: View {
var body: some View {
NavigationView {
Form {
Section {
List {
ForEach(0..<array1.count, id: \.self) { idx in
NavigationLink(destination: Text("1")) {
Text(array1[idx].name)
}
}
}
}
Section {
List {
ForEach(0..<array2.count, id: \.self) { idx in
NavigationLink(destination: Text("2")) {
Text(array2[idx].name)
}
}
}
}
}
}
}
}
All went great.
I got answer :
it doesn't work with NMutableOrderedSet because it's a reference-type - a class. (https://developer.apple.com/documentation/foundation/nsmutableorderedset)
Solution is to edit add() like this :
func add(managedObjectContext: NSManagedObjectContext) {
				let newSerieHistory = ExerciceSerieHistory(context: managedObjectContext)
				let newStorage = NSMutableOrderedSet(orderedSet: self.serieHistories)
				newStorage.add(newSerieHistory)
				self.serieHistories = newStorage		 // << fires publisher
				self.updateView()
		}