What are the digits in an ObjC method type encoding string?

馋奶兔 提交于 2019-12-03 08:11:10

问题


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

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


回答1:


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

- (void) setSomething:(id) anObject

To break it down:

  • 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.


来源:https://stackoverflow.com/questions/11491947/what-are-the-digits-in-an-objc-method-type-encoding-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!