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对文本以及二进制数据做了比较清晰 ...
随机推荐
- MyEclipse部署外部引用的jar到web-inf的lib目录下
在用MyEclipse开发java web项目的时候,引入了外部jar,都是以library的形式存在左边的explore中的,调试没有问题,但是部署之后呢,经常遇到个非常头疼的问题就是,这些jar不 ...
- 微信小程序之使用函数防抖与函数节流
函数防抖和函数节流都是老生常谈的问题了.这两种方式都能优化 js 的性能.有些人可能会搞混两个的概念.所以,我以自己的理解,来解释这两个概念的含义.并且列举在小程序中这两个方法的使用. 函数防抖: 英 ...
- Java学习:Debug调试程序
Debug追踪 Debug调试程序: 可以让代码逐行执行,查看代码执行的过程,调试程序中出现的bug 使用方式: 在行号的右边,鼠标左键单击,添加断点(每个方法的第一行,哪里有bug添加到哪里) 右键 ...
- 【华为云实战开发】10.经典的C++项目怎么在云端开发?【华为云技术分享】
1 概述 1.1 文章目的 本文主要想为研发C++项目的企业或个人提供上云指导,通过本文中的示例项目 “音频解析器”,为开发者提供包括项目管理,代码托管,代码检查,编译构建,测试管理的操作指导,覆盖软 ...
- 【mysql】 mybatis实现 主从表 left join 1:n 一对多 分页查询 主表从表都有查询条件 【mybatis】count 统计+JSON查询
mybatis实现 主从表 left join 1:n 一对多 分页查询 主表从表都有查询条件+count 需求: ======================================= ...
- c# 创建Excel com加载项Ribbon动态加载工作簿和工作表
使用 VSTO 创建外接程序,Gallery控件动态加载工作簿名称 代码如下: 加载工作簿名称: private void Gallery1_ItemsLoading(object sender, R ...
- VSCode 命令
淘宝 NPM 镜像 https://npm.taobao.org/ Ctrl+~ 显示终端 npm start 启动项目 cnpm install 安装模块
- Ubuntu系统下基于docker部署Jenkins环境
本文是在ubuntu环境下安装jenkins,jenkins运行在docker容器中, 至于docker如何安装,请参考https://www.cnblogs.com/xingyunqiu/p/115 ...
- 通过Nginx为网站配置二级域名
目录 配置域名解析 配置Nginx 重启Nginx 补充 需求:服务器上面运行多个项目:实现每个二级域名访问对应项目: 服务器:阿里云服务器:域名:阿里云注册: 配置域名解析 即配置DNS解析.一定要 ...
- vue项目的构建过程
确保已经安装了node和npm 1.安装vue-cli npm i vue-cli -g 2.安装vue-router npm i vue-router --save 3.安装vue-router n ...