Mike Ash’s Friday Q&A series of blog posts is a staple for anyone wanting to master iPhone (and Mac) programming. In this interview — inspired by a handful of his posts — Mike describes the Objective-C runtime. The runtime makes Objective-C dynamic. Mike describes the runtime in broad terms, dives into how objects are created and managed at runtime, details what happens when you send a message to an object, and explains how to can handle “no such method” cases dynamically at runtime.
You can listen using the Flash player below, download the MP3, or subscribe to the iPhone Developer Podcast using the instructions at the bottom of this post.
For easy scanning of the interview, here is what was covered and when:
- 1:15 – Objective-C runtime overview: managing classes, sending messages to them
- 2:30 – Loading classes/descriptions at process startup and allocating an instance of class
- 4:30 – Two things that makes an Objective-C object and object: chunk of memory and an “isa” pointer
- 5:00 – The “isa” pointer
- 6:15 – Keeping object information around at runtime
- 7:15 – Definitions: messages, methods and selectors
- 10:00 – What happens in the runtime when sending a message
- 11:45 – Objective-C methods translated into C functions;
- 13:00 – Using implicit parameters (e.g., the _cmd selector) in the C implementations
- 15:00 – Intercepting messages without a specific method behind them (i.e., method missing)
- 16:00 – Adding method implementations for a message at runtime
- 17:00 – Aliasing method implementation into multiple names
- 18:30 – Message forwarding: handling the message by another object
- 19:45 – Packing up and entire message and its parameters and using a “forward invocation” to handle it
- 20:46 – Invocations example: NSUndoManager
- 22:00 – Code Data and invocation objects
Thank You Ken Pespisa: A few weeks ago Ken Pespisa wrote me about the podcast’s audio quality. Specifically, he’d spent the time to put an older episode through the paces with Audacity to clean up the audio and then wrote a detailed document with instructions to duplicate his result. Bravo Ken for being constructive with your feedback. Reward Ken by buying his full screen browser app or relaxation app.
Keep up to date with our iPhone developers’ podcast
Subscribe to our iPhone Development Podcast in one of two great ways:
- Use the podcast’s feed with the feed app of your choice: http://podcast.mobileorchard.com/feed/podcast/
- Subscribe using iTunes by clicking here.