Type Encoding

Type Encodings

  The compiler encodes the return and argument types for each method in a character string and associates the string with the method selector.

  编译器把方法的返回值类型与参数类型encode成字符串,然后把此字符串与method selector关联起来。

  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.

  可以是任何可被传递给sizeof运算符作为参数的类型。

  

  The type code for an array is enclosed within square brackets; the number of elements in the array is specified immediately after the open bracket, before the array type. For example, an array of 12 pointers to floats would be encoded as:

  

  Structures are specified within braces, and unions within parentheses. The structure tag is listed first, followed by an equal sign and the codes for the fields of the structure listed in sequence. For example, the structure

  

  would be encoded like this:

  

  

原文地址:https://www.cnblogs.com/tekkaman/p/3561182.html