https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtHowMessagingWorks.html#//apple_ref/doc/uid/TP40008048-CH104-SW1

When objc_msgSend finds the procedure that implements a method, it calls the procedure and passes it all the arguments in the message. It also passes the procedure two hidden arguments:

  • The receiving object

  • The selector for the method

These arguments give every method implementation explicit information about the two halves of the message expression that invoked it. They’re said to be “hidden” because they aren’t declared in the source code that defines the method. They’re inserted into the implementation when the code is compiled.

Although these arguments aren’t explicitly declared, source code can still refer to them (just as it can refer to the receiving object’s instance variables). A method refers to the receiving object as self, and to its own selector as _cmd. In the example below, _cmd refers to the selector for the strange method and self to the object that receives a strange message.

self & _cmd的更多相关文章

  1. Swift #function 和 _cmd (Objective-C)

    NSStringFromSelector(_cmd); // Objective-C print(__FUNCTION__) // Swift 2 print(#function) // Swift ...

  2. object-c [self class] 和 [self _cmd]

    [self class] 返回当前类名 [self _cmd] 返回当前方法名 self 是类的隐藏的参数,指向当前当前调用方法的类 另一个隐藏参数是_cmd,代表当前类方法的selector

  3. 关于_cmd

    实际上是该方法名(@selector的名称). 比如: - (void)someCategoryMethod { NSString *string = objc_getAssociatedObject ...

  4. 第20月第14天 objc_getAssociatedObject _cmd

    1. - (CustomNavigationControllerDelegate *)customDelegate { return objc_getAssociatedObject(self, _c ...

  5. Runtime 中的 _cmd、 IMP

    IMP IMP-指向实际执行函数体的函数指针 #if !OBJC_OLD_DISPATCH_PROTOTYPES typedef void (*IMP)(void /* id, SEL, ... */ ...

  6. 常用的底层语法(objc_get,class_get,_cmd,objc_msgSend)

    一,关联 objc_get 1)建立关联:objc_setAssociatedObject:该函数需要四个参数:源对象,关键字,关联的对象和一个关联策略:当源对象销毁,关联的对象也会被销毁 源对象: ...

  7. NSStringFromSelector(_cmd)和self

    1._cmd是隐藏的参数,代表当前方法的selector,他和self一样都是每个方法调用时都会传入的参数,动态运行时会提及如何传的这两个参数, 你在方法里加入CCLOG(@\"%@, %@ ...

  8. IMP self _cmd

    The only way to circumvent dynamic binding is to get the address of a method and call it directly as ...

  9. zzw原创_cmd下带jar包运行提示 “错误: 找不到或无法加载主类 ”

    在windows下编译java,由于是临时测试一下文件,不想改classpath,就在命令行中用 -cp 或classpath引入jar包,用javac编译成功,便使用java带-cp 或classp ...

随机推荐

  1. golang基础语法

    golang语言的常量定义: const  filename="abc.txt"; const filename String="abc.txt" golang ...

  2. 记一个Redis分布式事务锁

    package com.mall.common; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory. ...

  3. pandas mode()填充nan异常问题

    df.mode()return的是一个frame,因为可能存在多个总数.那么用mode()来填充nan的时候就要注意了,如果直接 df.fillna(df.mode()) 会发现还是有很多空值没有填充 ...

  4. SQL怎么实现SLEEP功能(等待时间) -(转载)

    语法格式: WAITFOR DELAY N'小时数:分钟数:秒数.毫秒数' 等待100毫秒: SELECT GETDATE() WAITFOR DELAY N'00:00:00.100' SELECT ...

  5. Windows 查看端口占用进程并关闭

    当我们在运行一些软件需要特定软件(如tomcat)时,有可能会碰上端口被占用的情况,这时候我们可能就需要更改端口或把占用端口的进程结束掉,因为更换端口可能会导致当前环境产生一些的问题或是需要重新配置其 ...

  6. Jemeter学习环境部署。

    本文档中所有软件的下载地址 链接:https://pan.baidu.com/s/1RREUwlH7GtYMUWeiRjtWVg 提取码:zmjy 一.安装jdk 下载网盘中的jdk 双击jdk-8u ...

  7. 【SQL】各取所需 | SQL JOIN连接查询各种用法总结

    前面 在实际应用中,大多的查询都是需要多表连接查询的,但很多初学SQL的小伙伴总对各种JOIN有些迷糊.回想一下,初期很长一段时间,我常用的似乎也就是等值连接 WHERE 后面加等号,对各种JOIN也 ...

  8. drf--ModelSerializers序列化

    目录 drf--ModelSerializers序列化 项目准备 配置 settings.py 路由 多表设计 表关系分析 创建models 模型序列化 自定义模型序列化 api/serializer ...

  9. HTTP/2和Python的支持现状-2019-10

    背景: 大概2019年9月份,天猫全面升级了HTTP/2的支持,并且加强了HTTP/1的访问限制,也可能很早前就这么做了, 但之前一直没限制HTTP/1的访问.之所以发现这个问题,是因为写的爬虫突然失 ...

  10. Kali在NET模式下不能联网的解决方法

    1.第一种情况 首先ifconfig,可以看到没有正在工作的网卡,只有localhost 然后ifconfig -a,可以看到eth0这块网卡并没有离家出走,只是罢工了而已 接下来是关键步骤 leaf ...