I'm playing around with the new Xcode 15.0 beta (15A5160n) trying to implement an observable model that holds a weak reference to a UIScrollView
@Observable
final class BackingStore {
var initialOffset: CGPoint? = nil
weak var scrollView: UIScrollView? = nil {
willSet {
print(#function, self.scrollView, newValue, self.initialOffset)
// do something with newValue...
}
}
}
However I'm getting weird errors:
Cannot find 'newValue' in scope
Cannot find 'self' in scope; did you mean to use it in a type or extension context?
I even tried reaching for the _scrollView
and _$observationRegistrar
values instead but self isn't in scope apparently so instance variables aren't available even if they're added by a macro.
Is it not possible to use willSet
of didSet
in @Observable
marked classes? I read in the proposal that it was possible, though synthesised into the Registrar mutation methods.
Am I missing something?