Key-Value Observation

Key-Value Observation Defined

One of the applications of key-value coding is implementing the observer pattern. The observer pattern is used when you want an object to get a notification when the state of another object changes. This pattern is implemented with key-value observation in Objective-C.

To see a clear example of key-value observation, you need at least two objects. One object will be observed while the other object will be observing. For this example, let’s assume that you have two types of objects: a Project object and a Task object. Project objects maintain a list of Task objects. The project object ...

Get Objective-C Quick Syntax Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.