|
The performSelector: method is equivalent to sending an aSelector message directly to the receiver. For example, all three of the following messages do the same thing:
[該performSelector:方法等效於直接發送aSelector訊息發送到接收器。舉例來說,所有這三個以下訊息做同樣的事情:]
id myClone = [anObject copy];
id myClone = [anObject performSelector:@selector(copy)];
id myClone = [anObject performSelector:sel_getUid("copy")];
However, the performSelector: method allows you to send messages that aren’t determined until runtime. A variable selector can be passed as the argument:
[然而,performSelector:方法允許你發送那些沒有確定,直到運行時的訊息。變數選取器可作為參數傳遞:]
SEL myMethod = findTheAppropriateSelectorForTheCurrentSituation();
[anObject performSelector:myMethod];
The aSelector argument should identify a method that takes no arguments. For methods that return anything other than an object, use NSInvocation.
[該aSelector參數應該找出一種方法,它沒有參數。對於返回以外的任何一個對象的方法,使用NSInvocation。] |