Working with Action Messages

When a user interacts with an object, it sends an action message to an object in your code—usually the current view controller.

iOS includes a standard repertoire of action messages. The list is defined in a class called UIControl and appears in Figure 8.1. Buttons, sliders, text fields, and other standard UI objects are all subclasses of UIControl, so they inherit the items in this list. Most of this list is built into Interface Builder, so you can access it directly when you design your UI.

9781118462133-fg0801.tif

8.1 A first look at UIControl messages.

caution_exclamation_2c.eps

It makes no sense for a slider to send a UIControlEventEditingDidBegin message, because sliders aren’t editable. Don’t be confused by this. The same list is available for all objects, but that doesn’t mean all objects can send every kind of message. It’s up to you to work with the messages that make sense for each kind of control.

note_2c.eps

An enum is simply a list of named items. Internally, each name in the list is associated with a value. This makes it possible to use names in your code instead of numbers—which makes your code easier to read. You’ll often see message names and constant values defined in this way. (The numbers ...

Get iOS App Development Portable Genius 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.