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 ...
随机推荐
- Laravel集成Swoole教程
1.准备工作 安装 Laravel laravel new laravel-swoole 本人使用 valet 进行开发,可以使用 laravel-swoole.test 进行访问 2 ...
- laravel门面与服务提供者区别
laravel门面模式与服务提供者区别 以 Laravel 自带的文件系统为例,在 config/app.php 的配置文件的 providers 数组中,注册了一个服务提供者: Illuminate ...
- 【剑指offer】孩子们的游戏(圆圈中最后剩下的数)
题目描述 每年六一儿童节,牛客都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此.HF作为牛客的资深元老,自然也准备了一些小游戏.其中,有个游戏是这样的:首先,让小朋友们围成一个大圈.然后,他随机指 ...
- markdown入门基础------程序员必备技能
本人博客:https://blog.csdn.net/qq_39576571/article/details/97256521 ·首先:什么是markdown markdown是一种轻量级的标记语言, ...
- Python 监控脚本
Python 监控脚本 整体通过psutil模块动态获取资源信息.下为示例图: #!/usr/bin/env python # -*- coding: utf-8 -*- # @Time: 2019- ...
- 【vue】搭建vue环境以及要安装的所有东西
参考地址: https://www.cnblogs.com/laizhouzhou/p/8027908.html
- 上传文件大小与时间 Web.Config文件 httpRuntime 限制
httpRuntime <httpRuntime executionTimeout="90" maxRequestLength="40960" useF ...
- C# 填充客户端提交的值到T对象
/// <summary> /// 填充客户端提交的值到 T 对象 如appinfo = AppConvert.To<Appinfo>(context.Reques ...
- Matlab访问者模式
访问者(Visitor)模式的定义:将作用于某种数据结构中的各元素的操作分离出来封装成独立的类,使其在不改变数据结构的前提下可以添加作用于这些元素的新的操作,为数据结构中的每个元素提供多种访问方式.它 ...
- 时间格式在ios和安卓兼容性的问题:
在做项目时,在时间显示上遇到一个问题,取后台返回的时间时,在ios手机上时间不显示,安卓手机正常,最后通过Vconsole工具发现,ios不能支持用“—”分割的时间,此外后台返回的时间格式为x年x月x ...