1

There are some diagrams in Apple's documentation on Cocoa bindings, in the section "Bindings Message Flow". The diagrams show the typical pattern of event observers. In the second diagram, labeled "User Updates a Value in the User Interface", it shows how the method calls flow from a change in an NSTextField to the model. In the last step, at the model, it says "observing notifications are sent to observers of this model property". What confuses me here is that the NSTextField that started the change is itself an observer of the model, so now it is going to get notified of the change that it caused. This flow is shown in the first diagram, "Changing the Value of a Model Property".

I don't have any example code, I'm just trying to understand the design. Does Cocoa do something to stop this unnecessary notification? How does it work?

Related: I've recently been using Angular. It's an example of a different way of thinking about model-view binding and change propagation. I'm not sure I like it. Some problems with change listeners, according to Angular developers, are described here.

Community
  • 1
  • 1
Rob N
  • 15,024
  • 17
  • 92
  • 165

1 Answers1

0

If the text view is asked to change its object value, a simple pointer- or object-equality check should be sufficient (don't bother changing if the values are the same) but I'm not sure that's exactly what's happening here.

Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135