CHAPTER 22

image

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.