pub unsafe trait IvarType {
    type Type: InnerIvarType;

    const NAME: &'static str;
}
Expand description

Helper trait for defining instance variables.

This should be implemented for an empty marker type, which can then be used within Ivar to refer to the instance variable.

Safety

Really, Ivar should be marked as unsafe, but since we can’t do that we’ll mark this trait as unsafe instead. See Ivar for safety requirements.

Examples

Create an instance variable myCustomIvar with type i32.

use objc2::declare::IvarType;

// Helper type
struct MyCustomIvar;

unsafe impl IvarType for MyCustomIvar {
    type Type = i32;
    const NAME: &'static str = "myCustomIvar";
}

// `Ivar<MyCustomIvar>` can now be used

Required Associated Types

The type of the instance variable.

Required Associated Constants

The name of the instance variable.

Implementors