
Foundation. 133
In Objective-C, you can do a comparable feat. You rely on the
performSelector method of Objective-C and NSObject; it
takes a single parameter--a (SEL) that is usually exactly what
you have just tested in
respondsToSel ector"
if (anObject respondsToSelector- (SEL)theMethod) {
[anObject performSelector. (SEL)theMethod;
];
However, the framework will normally do much of this work
for you. If an object receives a message to which it cannot re-
ply (that is, it is asked to perform a method or function that it
does not have), it is then sent a new message--forwardIn-
vocati on. The original message is wrapped in an NSInvoca- ...