didSet not longer supported in observable?

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?!

I’m not really up to speed on this myself, but AFAIK the situation with didSet is still being discussed on Swift Evolution. See this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

didSet not longer supported in observable?
 
 
Q