Cocoa utilizes many features of the underlying Objective-C runtime. One powerful feature is the ability to create instances of classes that did not exist at the time an application was compiled and dynamically load and link new classes at runtime. Scripting languages such as AppleScript, Tcl, Ruby, Perl, and Python use this technique to provide interfaces to Cocoa. The core of this pattern is the
NSClassFromString() function that returns the class object with a specified name.
NSBundle augments this by implementing the method
–classNamed:, which can dynamically load code for the class if necessary. Once the named class object is obtained, instances can be created.
Dynamic creation enables scripting language bridges, plug-ins, ...