Struct objc2::runtime::Class

source ·
#[repr(C)]
pub struct Class(_);
Expand description

A type that represents an Objective-C class.

Implementations§

source§

impl Class

source

pub fn get(name: &str) -> Option<&'static Self>

Returns the class definition of a specified class, or None if the class is not registered with the Objective-C runtime.

source

pub fn classes_count() -> usize

Returns the total number of registered classes.

source

pub fn name(&self) -> &str

Returns the name of the class.

source

pub fn superclass(&self) -> Option<&Class>

Returns the superclass of self, or None if self is a root class.

source

pub fn metaclass(&self) -> &Self

Returns the metaclass of self.

source

pub fn instance_size(&self) -> usize

Returns the size of instances of self.

source

pub fn instance_method(&self, sel: Sel) -> Option<&Method>

Returns a specified instance method for self, or None if self and its superclasses do not contain an instance method with the specified selector.

source

pub fn instance_variable(&self, name: &str) -> Option<&Ivar>

Returns the ivar for a specified instance variable of self, or None if self has no ivar with the given name.

source

pub fn conforms_to(&self, proto: &Protocol) -> bool

Checks whether this class conforms to the specified protocol.

source

pub fn responds_to(&self, sel: Sel) -> bool

Check whether instances of this class respond to the given selector.

This doesn’t call respondsToSelector:, but works entirely within the runtime, which means it’ll always be safe to call, but may not return exactly what you’d expect if respondsToSelector: has been overwritten.

That said, it will always return true if an instance of the class responds to the selector, but may return false if they don’t directly (e.g. does so by using forwarding instead).

Trait Implementations§

source§

impl Debug for Class

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for Class

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a> MessageReceiver for &'a Class

source§

unsafe fn send_message<A, R>(self, sel: Sel, args: A) -> Rwhere A: MessageArguments, R: EncodeConvert,

Sends a message to self with the given selector and arguments. Read more
source§

unsafe fn send_super_message<A, R>( self, superclass: &Class, sel: Sel, args: A ) -> Rwhere A: MessageArguments, R: EncodeConvert,

Sends a message to a specific superclass with the given selector and arguments. Read more
source§

impl PartialEq<Class> for Class

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl RefEncode for Class

source§

const ENCODING_REF: Encoding = Encoding::Class

The Objective-C type-encoding for a reference of this type. Read more
source§

impl Eq for Class

source§

impl RefUnwindSafe for Class

source§

impl Send for Class

source§

impl Sync for Class

source§

impl UnwindSafe for Class

Auto Trait Implementations§

§

impl !Unpin for Class

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> AutoreleaseSafe for Twhere T: ?Sized,