I tried to migrate some code to SwiftData and Observable...doing this I wanted to mark a ViewModel-Class with @observable but get errors when using it in combination with didSet.
What's wrong with it?!
@Observable struct LADVAthletes {
var queryName : String = "" {
didSet {
guard oldValue != queryName else { return }
guard queryName.count < 2 else {
athletesList.removeAll()
return
}
}
}
var athletesList : [Athlete] = [Athlete]()
}
I get multiple Errors saying "Cannot find 'oldValue' in scope" "Instance member 'queryName' cannot be used on type 'LADVAthletes'; .... And so on...
What's wrong with it?!