Friday, April 3, 2015

Observation Pattern in Objective-C

There are three steps to using key-value observation:

• Send the addObserver:forKeyPath:options:context: message
to each object that is being observed.

• Override the method observeValueForKeyPath:ofObject:chan
ge:content: in the class definition of the object that is doing the
observing.

• Override the dealloc method and remove the observer reference

in the class definition of the object that is observing.