Implementing a protocol default implementation analogous to that of ObservableObject

Most likely, the default implementation of objectWillChange is just a regular publisher that doesn't check for changes itself (eg. by using reflection). Instead, what probably happens is that the @Published property wrapper triggers the objectWillChange of its enclosing instance when its wrapped value changes.

There's a hidden API to access the value in which a property wrapper is defined, which you could use to achieve the same thing — check this out: Accessing a Swift property wrapper’s enclosing instance | Swift by Sundell

3 Likes