zoukankan      html  css  js  c++  java
  • NSObject中的performSelector用法简介

    - (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协议]

  • 相关阅读:
    java获取服务器的ip和地址
    如何产生好的词向量
    谈谈评价指标中的宏平均和微平均
    在NLP中深度学习模型何时需要树形结构?
    Windows下MetaMap工具安装
    ML 感知机(Perceptrons)
    ML 神经网络 NeuralNetworks
    NLP-特征选择
    ML 逻辑回归 Logistic Regression
    ML 线性回归Linear Regression
  • 原文地址:https://www.cnblogs.com/iOSCain/p/4015488.html
Copyright © 2011-2022 走看看