ObjC方法类型编码字符串中的位数是多少? [英] What are the digits in an ObjC method type encoding string?

查看:87
本文介绍了ObjC方法类型编码字符串中的位数是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 Apple的有关Objective-C运行时类型编码字符串的文章 某些方法的类型字符串中包含数字.

I'm reading Apple's article about Objective-C runtime type encoding strings and some methods have numbers in their type strings.

v12@0:4@8中的数字是什么意思?

What do the numbers in v12@0:4@8 mean?

推荐答案

这看起来像是setter方法的编码,如下所示:

This looks like an encoding of a setter method like this:

- (void) setSomething:(id) anObject

要分解它:

  • v表示空返回类型
  • 12表示参数帧的大小(12个字节)
  • @0表示在参数帧的字节偏移量0处存在一个Objective-C对象类型(这是每个Objective-C方法中的隐式self对象)
  • :4表示在字节偏移量4处有一个选择器(这是每个方法中的隐式_cmd,它是用于调用该方法的选择器).
  • @8表示在字节偏移量8处还有另一种Objective-C对象类型.
  • v means void return type
  • 12 means the size of the argument frame (12 bytes)
  • @0 means that there is an Objective-C object type at byte offset 0 of the argument frame (this is the implicit self object in each Objective-C method)
  • :4 means that there is a selector at byte offset 4 (this is the implicit _cmd in every method, which is the selector that was used to invoke the method).
  • @8 means that there is another Objective-C object type at byte offset 8.

这篇关于ObjC方法类型编码字符串中的位数是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆