Hi, I'm trying out new SwiftData in a small Xcode project. It seems that the property observers didSet and willSet don't work anymore for swift data anymore. In code like this, the didSet does nothing and seems to never be called.
@Model public final class importConfig: Identifiable, ObservableObject{
@Attribute(.unique) public var id: UUID
/// Name of the configuration
var configName: String
/// Numbers App document to open
var numbersFilePath: URL?
/// Indicate wether current <numbersFilePath> Numbers App document has been loaded and analyzed
var isLoaded: Bool = false
/// Current selected sheet
var selectedSheetID: UUID? {
didSet {
selectedSheetID = nil
print("test")
}
}
}
Am I doing something wrong or is it the expected behavior ?
If it is the expected behavior, how can I add "business" rules when setting/unsetting value to model properties ?
I tried to add rules directly with .onchange()
in my views, but this way I have to repeat the same rules/code. Is there any alternative to do so ?
Thank you