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的更多相关文章

  1. runtime - 消息发送(objc_msgSend)

    http://www.jianshu.com/p/95c8cb186673 在OC中,我们对方法的调用都会被转换成内部的消息发送执行对objc_msgSend方法的调用,掌握好消息发送,可以让我们在编 ...

  2. 防御XSS攻击-encode用户输入内容的重要性

    一.开场先科普下XSS 跨站脚本攻击(Cross Site Scripting),为不和层叠样式表(Cascading Style Sheets, CSS)的缩写混淆,故将跨站脚本攻击缩写为XSS.恶 ...

  3. HttpPost过程中使用的URLEncoder.encode(something, encode)

    URLEncoder.encode("刘美美", "utf-8").toString()       =     %E5%88%98%E7%BE%8E%E7%B ...

  4. [LeetCode] Encode String with Shortest Length 最短长度编码字符串

    Given a non-empty string, encode the string such that its encoded length is the shortest. The encodi ...

  5. [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 ...

  6. 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'))

  7. javascript处理HTML的Encode(转码)和Decode(解码)总结

    HTML的Encode(转码)和解码(Decode)在平时的开发中也是经常要处理的,在这里总结了使用javascript处理HTML的Encode(转码)和解码(Decode)的常用方式 一.用浏览器 ...

  8. URLEncoder.encode 和 URLDecoder.decode 处理url的特殊参数

    在使用 url 的 queryString 传递参数时,因为参数的值,被DES加密了,而加密得到的是 Base64的编码字符串,类似于: za4T8MHB/6mhmYgXB7IntyyOUL7Cl++ ...

  9. Python3的decode()与encode()

    python3的decode()与encode() Tags: Python Python3 对于从python2.7过来的人,对python3的感受就是python3对文本以及二进制数据做了比较清晰 ...

随机推荐

  1. iphone如何安装mitmproxy的pem文件(当iphone无法使用邮箱时)

    背景描述: 我要安装mitmproxy描述文件 mitmproxy-ca-cert.pem , 说是用iphone自带的邮箱接收然后安装即可,但悲剧的邮箱坏了[提示:无法连接服务器],查了不少方法都无 ...

  2. AGC035

    Contest Page A 唯一会做的题/kk 题目相当于要求相邻三个的异或和为\(0\). 当我们放入了三个数\(a,b,c\)时,接下来的放入顺序显然一定是\(a,b,c,a,b,c,...\) ...

  3. Oracle排序(中文)

    一.中文排序      1. 按照笔划排序       select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_STROKE_M'); ...

  4. 获取html 中的内容 将前台的数据获取到后台 用 jquery 生成一个 form表单 提交数据

    使用js创建一个form表单 ,使用post上传到后台中 下面是代码.在获取html内容的时候使用了js节点来获取内容. parent:父节点.上一级的节点 siblings:兄弟节点.同一级别的节点 ...

  5. Ubuntu 使用scrapy-splash

    配置docker 1.更新apt索引: $ sudo apt-get update 2.安装包允许apt通过HTTPS使用仓库:  sudo dpkg --configure -a  sudo apt ...

  6. 我碰到的stackoverflow error

    出现这种问题,首先需要检查自己的代码: 要么代码小错误:或者逻辑错误: 如果出现循环调用更要仔细检查: 我的问题: 循环调用:一个实体他有自己的父栏目,含有子栏目的list集合:两者结果映射resul ...

  7. Java自学-类和对象 this

    Java 中的 this this 这个关键字,相当于普通话里的"我" 小明说 "我吃了" 这个时候,"我" 代表小明 小红说 " ...

  8. ASP.NET Core中返回 json 数据首字母大小写问题

    ASP.NET Core中返回 json 数据首字母大小写问题 在asp.net core中使用ajax请求动态绑定数据时遇到该问题 后台返回数据字段首字母为定义的大写,返回的数据没有问题 但是在前台 ...

  9. 45、导航钩子函数中使用next()和next('\指定路径')的区别:

    当在router.beforeEach((to, from, next) 钩子函数中使用: 1.使用next()时,直接跳转到下一页,没有再执行导航钩子函数 2.使用next('指定路径')跳转到指定 ...

  10. 基于RSA的WEB前端密码加密方案

    受制于WEB页面源码的暴露,因此传统的对称加密方案以及加密密钥都将暴露在JS文件中,同样可以被解密. 目前比较好的解决方案是WEB页面全程或用户登录等关键环节使用HTTPS进行传输. 另外一种解决方案 ...