Macro objc2::class

source ·
macro_rules! class {
    ($name:ident) => { ... };
}
Expand description

Gets a reference to a Class from the given name.

Panics

Panics if no class with the given name can be found.

To check for a class that may not exist, use Class::get.

Features

If the experimental "unstable-static-class" feature is enabled, this will emit special statics that will be replaced by dyld when the program starts up.

Errors that were previously runtime panics may now turn into linker errors if you try to use a class which is not available. Additionally, you may have to call msg_send![cls, class] on the result if you want to use it in a dynamic context (e.g. dynamically declaring classes).

See the corresponding section in the sel! macro for more details on the limitations of this. The "unstable-static-class-inlined" corresponds to the "unstable-static-sel-inlined" feature here.

Examples

let cls = class!(NSObject);