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. 030 ElasticSearch----全文检索技术05---基础知识详解03-聚合

    聚合可以让我们极其方便的实现对数据的统计.分析.例如: 什么品牌的手机最受欢迎? 这些手机的平均价格.最高价格.最低价格? 这些手机每月的销售情况如何? 实现这些统计功能的比数据库的sql要方便的多, ...

  2. 第八节:Asp.Net Core整合Log4net(官方的、微软的两种)

    一. 整合Log4net 1. 简单说明 对于log4net 官方的程序集而言,从2.0.7开始就支持.Net Core了,这里我们采用的是2.0.8,虽然好久没更新了,但不影响使用.Core版本与普 ...

  3. Qt 文件选项对话框弹出两次

    1 问题 ​ 在Qt 5.12.0 版本中,用 QFileDialog 类来做文件选择时候,发现当弹出对话框后,选择完文件后,又弹出文件选择对话框. 2 原因查找 2.1 代码 QFileDialog ...

  4. <面试题分享> 记两次58面试

    说明 来北京找工作,有个猎头看我的简历不错,帮我投了两个58同城的面试,投的都比较高,题也注重原理,较难,这里分享出来,给有需要的人和自己提个醒,保持空杯 面试题内容 2019.05.07 北京58企 ...

  5. 补习系列(17)-springboot mongodb 内嵌数据库【华为云技术分享】

    目录 简介 一.使用 flapdoodle.embed.mongo A. 引入依赖 B. 准备测试类 C. 完善配置 D. 启动测试 细节 二.使用Fongo A. 引入框架 B. 准备测试类 C.业 ...

  6. golang学习笔记 ---interface

    1. 什么是interface接口 interface 是GO语言的基础特性之一.可以理解为一种类型的规范或者约定.它跟java,C# 不太一样,不需要显示说明实现了某个接口,它没有继承或子类或“im ...

  7. 【mybatis】mybatis查询 结果 用map接收,无实体接收 + 关联子表 一并返回主子表的结果

    如果后台程序没有实体对应mysql的数据表. 而mybatis想要查询mysql这个数据表的数据,返回给应用程序. 应用程序该如何接收? =============================== ...

  8. [更新] Jetbrains IntelliJ IDEA 2019 的许可证密钥

    亲测有效.转载目的:提供一种方法,当然可以看一下原网站的更新及其他方法.转载:[更新] Jetbrains IntelliJ IDEA 2019 的许可证密钥(100%工作),By Gideon    ...

  9. MySQL数据类型之BLOB与TEXT及其最大存储限制

    https://blog.csdn.net/q3dxdx/article/details/51014357 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.n ...

  10. Identity和IdentityServer的区别及联系

    关于Identity和IdentityServer初学的时候可能会有一些疑惑(虽然我也不是很精深吧),但是,这里说一下自己关于这两者的一些理解,如有错误,欢迎指正 总体上, ASP.NET Core ...