Information Technology Reference
In-Depth Information
The Type option selects id , or the class of the object sending the message— UIButton , in this example. Use
id when you use the same method to handle messages from multiple different objects. You can then add extra
code that determines the class of the object that sent the message. You also can use id if you don't need to read
the object's properties. Use a specific class when you need to read information from the button or change one of
its properties.
In this example, we need to know that the button was tapped, but we don't need to know its color, position, or
anything else about it; the default id setting is fine.
NOTE
In Objective-C, id is a catch-all class label. It means “this object is some class, but we either don't know or don't
care which one.”
The Event option duplicates the standard list of possible events. If you change your mind about the event that
should trigger the action, you can select a different option here. Usually, you won't.
The Arguments option selects one of the following: None, Sender, or Sender and Event. Choose None when
you don't need to know anything about the sender object. Choose Sender when you want to read the sender
object's properties. Choose Sender and Event when you also want to read information from an optional
UIEvent object that arrives with the message—for example, if you want to find the event timestamp.
TIP
To save time, you can leave the default options in this dialog box as they are. You'll get an action method that in-
cludes an (id) sender parameter. Your code can ignore this parameter if it doesn't need it.
CROSS-REFERENCE
The File's Owner icon in the dialog box is explained in Chapter 8.
FIGURE 7.25
When adding an action, add a name and ignore the rest, unless your code demands the extra features.
Search WWH ::




Custom Search