This is a SwiftUI Mac App.
There is an observable object with a published array
class AllObjects : ObservableObject {
@Published var theItems = [Item]()
}
In the View, observed with:
@ObservedObject var allObjects : AllObjects
Item class is :
class Item: ObservableObject, Identifiable {
let id = UUID()
var placeNo = 1
// Other properties
}
When I switch dark / light mode within the app (with a toggle)
@Environment(\.colorScheme) var colorScheme
the ObservedObject allObjects is modified: array is emptied: allObjects.theItems is now an empty array.
What could cause the change to theItems ? I have checked that the only func un which theItems is reset to [] is not called.