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对文本以及二进制数据做了比较清晰 ...
随机推荐
- Git flow 工作流与规范
概述 简版图: PS. 可能用到的命令: 1.从指定 commit拉出新分支 git checkout commitId -b 本地新branchName git checkout 9fbc3d0 ...
- SQL Server的外键必须引用的是主键或者唯一键(转载)
问: In SQL Server , I got this error -> "There are no primary or candidate keys in the refere ...
- 面对代码中过多的if...else的解决方法
原 6个实例详解如何把if-else代码重构成高质量代码 置顶 2017年09月11日 23:47:12 yinnnnnnn 阅读数 21433更多 分类专栏: # 理论 版权声明:本文为博主原创 ...
- C#实现服务器间文件同步
using System.IO; /// <summary> /// 远程登陆服务器 /// </summary> /// <param name="remot ...
- ffmpeg命令参数详解
ffmpeg命令参数详解 http://linux.51yip.com/search/ffmpeg ffmpeg图片加滤镜效果 参考:https://cloud.tencent.com/develop ...
- drf之接口规范
web接口 # 请求工具:postman => https://www.getpostman.com/ # 接口:url链接,通过向链接发生不同的类型请求与数据得到相应的响应数据 # http: ...
- 浅谈Object.prototype.toString.call()方法
在JavaScript里使用typeof判断数据类型,只能区分基本类型,即:number.string.undefined.boolean.object.对于null.array.function.o ...
- 编写可维护的JavaScript-随笔(六)
避免空比较 If(item !== null){ item.sort(); Item.forEach(function(item){ //执行代码 } } } 以上判断中item期待的是数组类型的,但 ...
- vue-cli2和3中的config
最近在网上找了个vue搭建的后台管理的框架,在使用的时候发现没有了config和build文件夹,所以当时就蒙圈了,以为是作者自己改了什么东西,所以感觉自己不知道从何下手了,不过通过查资料发现原来是v ...
- Jmeter jmeter-server.bat 无法启动
问题现象: 解决方法: 找到如下文件: 在目录\apache-jmeter-5.0\bin下,打开名为jmeter.properties的文件 找到server.rmi.ssl.disable=fal ...