You have already seen the Target-Action pattern. This is one form of callbacks that is used by UIKit: When a button is tapped, it sends its action message to its target. This typically triggers code that you have written.

A button’s life is relatively simple. For objects with more complex lives, like a text field, Apple uses the delegation pattern. You introduce the text field to one of your objects: This is your delegate, when anything interesting happens in your life, send a message to him. The text field keeps a pointer to its delegate. Many of the message it sends to its delegates are informative: OK, I am done editing!. Here are some of those:

-​ ​(​v​o​i​d​)​t​e​x​t​F​i​e​l​d​D​i​d​E​n​d​E​d​i​t​i​n​g​:​(​U​I​T​e​x​t​F​i​e​l​d​ ...

Get iOS Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

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