Post

Replies

Boosts

Views

Activity

Reply to Update SwiftUI View on NSManagedObject edit
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())
Aug ’20
Reply to Two lists in a view getting their text confused
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.
Jul ’20
Reply to Detect change in NSMutableOrderedSet with Combine
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) { &#9;&#9;&#9;&#9;let newSerieHistory = ExerciceSerieHistory(context: managedObjectContext) &#9;&#9;&#9;&#9;let newStorage = NSMutableOrderedSet(orderedSet: self.serieHistories) &#9;&#9;&#9;&#9;newStorage.add(newSerieHistory) &#9;&#9;&#9;&#9;self.serieHistories = newStorage&#9;&#9; // << fires publisher &#9;&#9;&#9;&#9;self.updateView() &#9;&#9;}
Jul ’20