An oft forgotten feature of Cocoa and Cocoa Touch development is Key-Value Observing, or KVO. It’s an ingenious system that lets us notify one class if something changes in another class. Or more specifically, if an object’s property changes in one instance, another object can react to it.
This sounds way more complicated than it really is. Think of all those times when you write a protocol, or create an NSNotification to tell another class to do something. Both those approaches are valid, and sometimes necessary, but there is a simpler alternative that I often forget when I’m hacking away.
Here’s how it works, shown with a simple example.