self & _cmd
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的更多相关文章
- Swift #function 和 _cmd (Objective-C)
NSStringFromSelector(_cmd); // Objective-C print(__FUNCTION__) // Swift 2 print(#function) // Swift ...
- object-c [self class] 和 [self _cmd]
[self class] 返回当前类名 [self _cmd] 返回当前方法名 self 是类的隐藏的参数,指向当前当前调用方法的类 另一个隐藏参数是_cmd,代表当前类方法的selector
- 关于_cmd
实际上是该方法名(@selector的名称). 比如: - (void)someCategoryMethod { NSString *string = objc_getAssociatedObject ...
- 第20月第14天 objc_getAssociatedObject _cmd
1. - (CustomNavigationControllerDelegate *)customDelegate { return objc_getAssociatedObject(self, _c ...
- Runtime 中的 _cmd、 IMP
IMP IMP-指向实际执行函数体的函数指针 #if !OBJC_OLD_DISPATCH_PROTOTYPES typedef void (*IMP)(void /* id, SEL, ... */ ...
- 常用的底层语法(objc_get,class_get,_cmd,objc_msgSend)
一,关联 objc_get 1)建立关联:objc_setAssociatedObject:该函数需要四个参数:源对象,关键字,关联的对象和一个关联策略:当源对象销毁,关联的对象也会被销毁 源对象: ...
- NSStringFromSelector(_cmd)和self
1._cmd是隐藏的参数,代表当前方法的selector,他和self一样都是每个方法调用时都会传入的参数,动态运行时会提及如何传的这两个参数, 你在方法里加入CCLOG(@\"%@, %@ ...
- IMP self _cmd
The only way to circumvent dynamic binding is to get the address of a method and call it directly as ...
- zzw原创_cmd下带jar包运行提示 “错误: 找不到或无法加载主类 ”
在windows下编译java,由于是临时测试一下文件,不想改classpath,就在命令行中用 -cp 或classpath引入jar包,用javac编译成功,便使用java带-cp 或classp ...
随机推荐
- linux中用一个.sh文件执行多个.sh文件
建一个文件夹存放你自己的.sh文件(用命令行操作) 先进入到: cd usr/local/sbin 目录里面 然后再新建一个文件夹: sudo mkdir myshell 建一个文件夹专门存放自己 ...
- Win10 系统直接在目录下打开cmd
每次用cmd命令,就要定位到当前文件夹,很麻烦 这里介绍一种直接定位到要操作的文件夹的方法: 操作步骤: (1)选择要cmd的文件夹,按住Shift键,鼠标右键快捷方式,先打开Powershell窗口 ...
- java自带的xml解析工具类
public class JaxbUtil { /** * java对象转换为xml文件 * * @param xmlPath xml文件路径 * @param load java对象.Class * ...
- 快速获取更丰富的Sitecore体验数据库
无论您是否立即使用Sitecore的营销功能,我们强烈建议您执行这三项任务,以使您的数据收集更加丰富,并为您以后的决策留下良好的位置. Sitecore的体验数据库,即xDB,是Sitecore营销平 ...
- Java学习:static 关键字概述
static 关键字概述 一旦用了static关键字,那么这样的内容不再属于对象自己.而是属于类的,所以凡是本类的对象,都共享同一份. 如果没有static关键字,那么必须首先创建对象,然后通过对象才 ...
- golang 源码文件
Go源码文件分三个种类: 1)命令源码文件:如果一个源码文件被声明属于main代码包,且该文件代码中包含无参数声明和结果声明的main函数,则它就是命令源码文件.命令源码文件可以通过go run命令直 ...
- 一起来学习.net core程序使用中介者模式:MediatR插件
中介者模式是一种常见的设计模式,旨再降低程序的耦合性,因为传统的三层模式层层之间需要显示的调用,必须上层依赖下层,耦合性很高,为了解耦,将所有的指令单独放在一个位置处理,其他位置均通过这个位置来间接的 ...
- C# Winform 只允许输入数字
if (!(e.KeyChar >= '0' && e.KeyChar <= '9' || e.KeyChar == '.')) e.Handled = true; if ...
- Echarts 学习系列(3)-Echarts动态数据交互
写在前面 上一小节,我们总结了折线(面积)图.柱状(条形)图.饼(圆环)图类型的图表. 但是,都是静态的.接下来的,这一小节,总结的是Echarts 动态数据的交换. 前置条件 开发环境:win10 ...
- 使用HttpClient访问接口(Rest接口和普通接口)
这里总结一下使用HttpClient访问外部接口的用法.后期如果发现有什么缺陷会更改.欢迎读者指出此方法的不足之处. 首先,创建一个返回实体: public class HttpResult { // ...