官方文档介绍
- (id)performSelector:(SEL)aSelector;
Description
Sends a specified message to the receiver and returns the result of
the message. The performSelector: method is equivalent to sending an
aSelector message directly to the receiver. For example, the following
messages all do the same thing:
Listing 1
id aClone = [anObject copy];
id aClone = [anObject performSelector:@selector(copy)];
id aClone = [anObject performSelector:sel_getUid("copy")];
The performSelector: method allows you to send messages that aren’t
determined until run-time. This means that you can pass a variable
selector as the argument:
Listing 2
SEL aSelector = findTheAppropriateSelectorForTheCurrentSituation();
id returnedObject = [anObject performSelector:aSelector];
</