Movatterモバイル変換


[0]ホーム

URL:


Previous:, Up:Type Encoding   [Contents][Index]


9.3.3 Method Signatures

This section documents the encoding of method types, which is rarelyneeded to use Objective-C. You should skip it at a first reading; theruntime provides functions that will work on methods and can walkthrough the list of parameters and interpret them for you. Thesefunctions are part of the public “API” and are the preferred way tointeract with method signatures from user code.

But if you need to debug a problem with method signatures and need toknow how they are implemented (i.e., the “ABI”), read on.

Methods have their “signature” encoded and made available to theruntime. The “signature” encodes all the information required todynamically build invocations of the method at runtime: return typeand arguments.

The “signature” is a null-terminated string, composed of the following:

For example, a method with no arguments and returningint wouldhave the signaturei8@0:4 if the size of a pointer is 4. Thesignature is interpreted as follows: thei is the return type(anint), the8 is the total size of the parameters inbytes (two pointers each of size 4), the@0 is the firstparameter (an object at byte offset0) and:4 is thesecond parameter (aSEL at byte offset4).

You can easily find more examples by running the “strings” programon an Objective-C object file compiled by GCC. You’ll see a lot ofstrings that look very much likei8@0:4. They are signaturesof Objective-C methods.


Previous:@encode, Up:Type Encoding   [Contents][Index]


[8]ページ先頭

©2009-2026 Movatter.jp