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对文本以及二进制数据做了比较清晰 ...
随机推荐
- Java8 新特性 默认方法
默认方法为什么出现 默认方法的出现是因为在java8设计的过程中,因为加入了Lamdba表达式,和函数式接口,所以在非常多的接口里面要加入新的方法,但是如果在接口里面直接加入新的方法,那么以前写的所有 ...
- Redis GEO地理位置信息,查看附近的人
在之前的一篇文章<SpringBoot入门教程(五)Java基于MySQL实现附近的人>,我们介绍了Java基于MySQL实现查找附近的人的功能.今天就来研究研究"查找附近的人& ...
- DDR3(2):初始化
调取 DDR3 IP核后,是不能直接进行读写测试的,必须先进行初始化操作,对 IP 核进行校验.本篇采用 Modelsim 软件配合 DDR3 IP核生成的仿真模型,搭建出 IP核的初始化过程. 一. ...
- 『序列 莫队 dp预处理』
序列 Description 给定长度为n的序列:a1,a2,-,an,记为a[1:n]. 类似地,a[l:r](1≤l≤r≤N)是指序列:al,al+1,-,ar-1,ar.若1≤l≤s≤t≤r≤n ...
- ES集群7.3.0设置快照,存储库进行索引备份和恢复等
说明:三台ES节点组成ES集群,一台kibana主机,版本均是7.3.0,白金试用版 官方地址:https://www.elastic.co/guide/en/elasticsearch/refere ...
- Mycat分布式数据库架构解决方案--Mycat实现数据库分表
echo编辑整理,欢迎转载,转载请声明文章来源.欢迎添加echo微信(微信号:t2421499075)交流学习. 百战不败,依不自称常胜,百败不颓,依能奋力前行.--这才是真正的堪称强大!!! 准备工 ...
- Beego 学习笔记二:第一个项目
第一个MVC项目 1> 使用beego命令,创建一个项目 首先切换到创建项目的位置,输入bee new firstweb命令,创建成功之后会出现一个名为firstweb的文件夹 2> ...
- 智能制造进入下半场?APS如何进行优化
按照现在算法和计算机处理能力的发展,现在资源优化的方向已经逐渐摒弃,而是在更系统的“有限产能计划的”框架内一并解决产能和物料的问题. 我们所看到的新近涌现出来的很多APS系统.但碍于算法的复杂程度,在 ...
- python-gitlab 之更改 merge_method
参考: https://docs.gitlab.com/ee/api/projects.html https://python-gitlab.readthedocs.io/en/stable/gl_o ...
- 后台根据html邮件模板发送邮件
HTML邮件模板: xxxxxxx 在线模板的方式: String fileName = "http://localhost:8080/xxxxxxx.html"; URL url ...