How are method names stored in temporary memory?

Of interest, how are method names stored in memory in compiled Objective-C? The main reason for interest is understanding dynamic text input.

Thanks in advance!

+4
source share
1 answer

A source for the runtime is available, by the way, if you really want to go deeper.

Shortly speaking; method names β€” their selectors β€” are stored as C strings in the binary traversal poppy. That is, if you have a method -(void)foo:(int)a bar:(int)b; , in mach-o there will be a selector line foo:bar:

Type encoding information is also stored in another segment of the mach-o file. This type information β€” for which there is an API in the runtime to retrieve it β€” describes the return type and arguments to the method.

Please note that type information is incomplete. Also note that using type information to determine how to generally encode / decode arguments and return a value from a method is a direct pain.

+3
source

All Articles