Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typical Objective C message implementation

Tags:

objective-c

I'm wondering how does a typical (or at least Apple's) implementation of the Objective C dynamic messaging system look. How are selectors handled at compile and run time, what does NSObject* really point at, how is the method implementation found in there.

In C++, we have virtual functions; how they are implemented is officially an implementation detail, but in reality a VF table pointer as a first data member is pretty much a given. I'm wondering if there's a similarly ubiquitous way of implementing ObjC's class system.

like image 343
Seva Alekseyev Avatar asked Jul 16 '26 06:07

Seva Alekseyev


1 Answers

This can be quite lengthy. ughoavgfhw’s answer is a good start.

I’d recommend reading the following blog posts:

  • bbum’s objc_msgSend() Tour Parts 1, 2, 3, 4
  • mikeash’s Friday Q&A 2009-03-20: Objective-C Messaging

And if you’re not afraid of delving into source code, objc and clang are available at Apple’s Open Source Web site.