pub fn load_or_register_class<F>(
    superclass_name: &'static str,
    subclass_name: &'static str,
    config: F
) -> *const Class where
    F: Fn(&mut ClassDecl) + 'static, 
Expand description

Attempts to load a subclass, given a superclass_name and subclass_name. If the subclass cannot be loaded, it’s dynamically created and injected into the runtime, and then returned. The returned value can be used for allocating new instances of this class in the Objective-C runtime.

The config block can be used to customize the Class declaration before it’s registered with the runtime. This is useful for adding method handlers and ivar storage.

If the superclass cannot be loaded, this will panic. If the subclass cannot be created, this will panic. In general, this is expected to work, and if it doesn’t, the entire framework will not really work.

There’s definitely room to optimize here, but it works for now.