objc_msgSend method_getTypeEncoding 与 @encode
struct objc_method {
SEL _Nonnull method_name OBJC2_UNAVAILABLE;
char * _Nullable method_types OBJC2_UNAVAILABLE;
IMP _Nonnull method_imp OBJC2_UNAVAILABLE;
}
@encode:
将数据类型编码成char*(字符串)形式
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/ObjCRuntimeGuide.pdf
To assist the runtime system, the compiler encodes the return and argument types for each method in a character string and associates the string with the method selector. The coding scheme it uses is also useful in other contexts and so is made publicly available with the @encode() compiler directive. When given a type specification, @encode() returns a string encoding that type. The type can be a basic type such as an int, a pointer, a tagged structure or union, or a class name—any type, in fact, that can be used as an argument to the C sizeof() operator.
method_getTypeEncoding
使用@encode将消息编码成字符串形式。
编码的格式按照
id objc_msgSend(id self, SEL op, ...)
参量的顺序进行布局。
-(void)log:(SEL)sel
{
Method xxx = class_getInstanceMethod(self.class, sel);
char *ret = method_getTypeEncoding(xxx);
NSLog(@"sel:%s, %s", sel, ret);
}
举例:
-(void)hello
v16@0:8
-(id)hello:(id)x
@24@0:8@16
-(void)hello:(id)x :(id)e
v32@0:8@16@24
解读:
按照文档上的说明,和objc_msgSend的参量顺序
A void v
A method selector (SEL) :
An object (whether statically typed or typed id) @
进行拆解解读
v16(返回类型为空) @0(receiver id类型) :8(SEL标示)
v32(返回类型为空) @0(receiver id类型) :8(SEL标示)@16(参量 id类型)@24(参量 id类型)
objc_msgSend method_getTypeEncoding 与 @encode的更多相关文章
- runtime - 消息发送(objc_msgSend)
http://www.jianshu.com/p/95c8cb186673 在OC中,我们对方法的调用都会被转换成内部的消息发送执行对objc_msgSend方法的调用,掌握好消息发送,可以让我们在编 ...
- 防御XSS攻击-encode用户输入内容的重要性
一.开场先科普下XSS 跨站脚本攻击(Cross Site Scripting),为不和层叠样式表(Cascading Style Sheets, CSS)的缩写混淆,故将跨站脚本攻击缩写为XSS.恶 ...
- HttpPost过程中使用的URLEncoder.encode(something, encode)
URLEncoder.encode("刘美美", "utf-8").toString() = %E5%88%98%E7%BE%8E%E7%B ...
- [LeetCode] Encode String with Shortest Length 最短长度编码字符串
Given a non-empty string, encode the string such that its encoded length is the shortest. The encodi ...
- [LeetCode] Encode and Decode Strings 加码解码字符串
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over th ...
- UnicodeEncodeError: 'ascii' codec can't encode characters in position 820-823: ordinal not in range(128)
真是奇怪了,在itermi里 print(data) 就能直接运行,而在sublime里,就非得写成这样 print(data.encode('utf-8'))
- javascript处理HTML的Encode(转码)和Decode(解码)总结
HTML的Encode(转码)和解码(Decode)在平时的开发中也是经常要处理的,在这里总结了使用javascript处理HTML的Encode(转码)和解码(Decode)的常用方式 一.用浏览器 ...
- URLEncoder.encode 和 URLDecoder.decode 处理url的特殊参数
在使用 url 的 queryString 传递参数时,因为参数的值,被DES加密了,而加密得到的是 Base64的编码字符串,类似于: za4T8MHB/6mhmYgXB7IntyyOUL7Cl++ ...
- Python3的decode()与encode()
python3的decode()与encode() Tags: Python Python3 对于从python2.7过来的人,对python3的感受就是python3对文本以及二进制数据做了比较清晰 ...
随机推荐
- Lab_1:练习2——使用qemu执行并调试lab1中的软件
一.实验内容 为了熟悉使用qemu和gdb进行的调试工作,我们进行如下的小练习: (一)从CPU加电后执行的第一条指令开始,单步跟踪BIOS的执行. (二)在初始化位置0x7c00设置实地址断点,测试 ...
- 【题解】子序列个数 [51nod1202] [FZU2129]
[题解]子序列个数 [51nod1202] [FZU2129] 传送门:子序列个数 \([51nod1202]\) \([FZU2129]\) [题目描述] 对于给出长度为 \(n\) 的一个序列 \ ...
- Direct Buffer介绍
Direct Buffer 前言 上篇文章Buffer末尾中谈到堆内Buffer(Heap Buffer)和直接Buffer(Direct Buffer)的概念,但是却一笔带过,并未涉及其细节,这篇文 ...
- vue实现跨域请求的设置
vue实现跨域请求,需要在vue.config.js里添加以下设置 proxy: { '/service/rest': { target: 'http://localhost:8080/autotab ...
- C# vb .net图像合成-合成矩形
在.net中,如何简单快捷地实现图像合成呢,比如合成文字,合成艺术字,多张图片叠加合成等等?答案是调用SharpImage!专业图像特效滤镜和合成类库.下面开始演示关键代码,您也可以在文末下载全部源码 ...
- 彻底理解javascript中的this指针
http://javascriptissexy.com/understand-javascripts-this-with-clarity-and-master-it/ https://www.benn ...
- spark存储模块之内存存储--MemeoryStore
MemeoryStore 上一节,我们对BlockManager的主要写入方法做了一个整理,知道了BlockMananger的主要写入逻辑,以及对于块信息的管理.但是,由于spark的整个存储模块是在 ...
- 为什么K8s会成为主流?
容器技术和K8s是云原生概念的核心和基础.云计算诞生已有超过10年,但云计算时代的应用到底该是什么样子,一直没人能说清楚,也没人能确定云计算的基础架构将会如何发展.在K8s出现之前,没人设想过会有一个 ...
- jquery设置css,animate设置多个属性
$("p").css("color","red"); $("p").css({ "font-size" ...
- Centos7 rsync+inotify实现实时同步更新
inotify slave部署 把master上指定文件下载到本地的主机指定目录 yum install rsync –y [root@localhost ~]# useradd rsync ...