码迷,mamicode.com
首页 > 其他好文 > 详细

NSObject中的performSelector用法简介

时间:2014-10-10 13:29:34      阅读:288      评论:0      收藏:0      [点我收藏+]

标签:des   style   color   io   os   使用   ar   for   strong   

- (id)performSelector:(SEL)aSelector

Description

[说明]

Sends a specified message to the receiver and returns the result of the message. (required)

[发送指定消息的接收和返回消息的结果。(必填)]

 

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。]

Parameters

[参数]

aSelector

A selector identifying the message to send. If aSelector is NULL, an NSInvalidArgumentException is raised.

[选择器确定要发送的消息。如果aSelector为NULL,一个NSInvalidArgumentException提高。]

Returns

[返回]

An object that is the result of the message.

[一个对象,该对象是消息的结果。]

Availability

[可用性]

OS X (10.0 and later)

[OS X 10.0及更高版本]

Declared In

[宣称]

NSObject.h

Reference

[参考]

NSObject Protocol Reference

[参考NSObject协议]

NSObject中的performSelector用法简介

标签:des   style   color   io   os   使用   ar   for   strong   

原文地址:http://www.cnblogs.com/iOSCain/p/4015488.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!