What is the correct way to observe the changes from within a nested `ObservableObject`?

There was an earlier thread on the same topic, and the conclusion seemed to be that two underscore-prefixed features are at play;

  • a static subscript protocol member of ObservableObject with the argument labels _enclosingInstance:wrapped:storage:, and
  • _forEachField(of:options:body:), which is more flexible than Mirror and hidden from ordinary code using @_spi(Reflection); hat tip to @AlexanderM!

So yes, there is reflection behind the scenes.

3 Likes