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 ...
随机推荐
- 哈夫曼树的构建(C语言)
哈夫曼树的构建(C语言) 算法思路: 主要包括两部分算法,一个是在数组中找到权值最小.且无父结点两个结点位置,因为只有无父结点才能继续组成树: 另一个就是根据这两个结点来修改相关结点值. 结构定义 ...
- Qt SDK Issue cstdlib: fatal error: stdlib.h: No such file or directory
*To reproduce the issue, I've tried the following solutions which did not help:* *1) Globally remove ...
- Vim 入门教程
Vim 入门教程 转载请保留以上信息 Vim 的教程相对比较零散,系统的教程比较少,我也阅读过不少教程,走过很 多弯路.借着 Vim-china 组织组建这一契机,整理下自己学习过的内容, 分享给大家 ...
- [转帖]关于 ./configure
./configure --prefix=/usr/local/scws --prefix选项是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr/local/bin,库文件默认放在/ ...
- Java的常用API之Object类简介
Object类 1.toString方法在我们直接使用输出语句输出对象的时候,其实通过该对象调用了其toString()方法. 2.equals方法方法摘要:类默认继承了Object类,所以可以使用O ...
- Java多线程分批发送消息的小例子
需求: 假设有10万个用户,现在节假日做活动,需要给每个用户发送一条活动短信,为了提高程序的效率,建议使用多线程分批发送. 这里值得注意的是: 每开一个线程都会占用CPU的资源,所以线程根据所需要的条 ...
- Elasticsearch常见用法-入门
前台启动 默认是只有本地可以访问 ./bin/elasticsearch 远程访问 修改elasticsearch.yml,把network.host(注意配置文件格式不是以 # 开头的要空一格, : ...
- eclipse的debug模式的F5,F6按键失灵
在使用eclipse Mars.1 Release (4.5.1)开发过程中,发现debug模式下的快捷键无法使用,全部失效了.秉持坚决自己解决绝不求人的态度我艰苦的在度娘上寻求解决办法,有的说是快捷 ...
- BAPI_TRANSACTION_COMMIT
通过NCO执行SAP里面的 BAPI_TRANSACTION_COMMIT 并不能直接生效,类似SQL 里面的事物一样,需要有开始与结束,正确的方式如下: RfcSessionManager.Begi ...
- EF之DataBase添加新表
由于需要新增的XML数据较多,可以另起项目,将新增的XML数据复制到原来的EF