Core application logic
Languages / Knowledge library
Objective-C
message dispatch cocoa and apple application code
Why learn Objective-C?
Useful for maintaining established Apple-platform code and understanding Swift interoperability. Consult current platform documentation for deployment requirements.
Where it came from
Objective-C extends C with object-oriented features and a dynamic runtime. Apple's archived guide documents its use with Cocoa and related application frameworks.
Build your understanding
Work through these exercises in order. Try the task before opening a reference.
- Declare a class with a property and method.
- Send a message and inspect the return value.
- Use a protocol to define an interface.
- Explain object ownership under automatic reference counting.
- Test a small interoperability boundary with Swift.
Documentation and sources
- Apple language guide (archived) (developer.apple.com)
Catalog research notes
- Research snapshot: September 9, 2026. This entry summarizes the linked primary documentation; it does not assert a latest release version.
Connect the ideas
Explore next
Real World Example
Dynamic Message Dispatch for Plugin Architectures
Developers building modular iOS applications that require third-party plugin integration without recompiling the core application.
The business problem
Static linking prevents the core application from invoking methods on dynamically loaded modules because the compiler lacks the necessary interface definitions at build time.
How this topic solves it
Objective-C utilizes a dynamic runtime that defers method binding until execution. By sending messages to objects, the runtime searches the object's class hierarchy for a matching selector, allowing the app to interact with plugins that were not present during the initial compilation.
- Define a common protocol that both the host application and the plugin module adopt to ensure interface consistency.
- Load the external plugin bundle into the application process at runtime using NSBundle.
- Instantiate the plugin class dynamically using the runtime system.
- Send messages to the instantiated object using the selector defined in the protocol.
- Handle potential runtime errors using NSError if the plugin fails to respond to the expected message.
The flow illustrates how the host app interacts with a plugin via the Objective-C runtime.
Loads external code
Dynamically loaded instance
Performs message lookup
- Host App → Loads bundle → NSBundle
- NSBundle → Instantiates class → Plugin Object
- Host App → Sends message → Runtime System
- Runtime System → Dispatches to method → Plugin Object
Expected business outcome
The application achieves high extensibility, enabling the loading of new features as separate bundles that communicate seamlessly with the core system via dynamic message dispatch.
Limitations and checks
Dynamic dispatch introduces a slight runtime overhead compared to static function calls. Developers can check for performance bottlenecks by profiling the application in Instruments to monitor message-sending frequency in tight loops.