[−][src]Struct objc::declare::ClassDecl
A type for declaring a new class and adding new methods and ivars to it before registering it.
Methods
impl ClassDecl
[src]
pub fn new(name: &str, superclass: &Class) -> Option<ClassDecl>
[src]
Constructs a ClassDecl
with the given name and superclass.
Returns None
if the class couldn't be allocated.
pub fn root(
name: &str,
intitialize_fn: extern "C" fn(_: &Class, _: Sel)
) -> Option<ClassDecl>
[src]
name: &str,
intitialize_fn: extern "C" fn(_: &Class, _: Sel)
) -> Option<ClassDecl>
Constructs a ClassDecl
declaring a new root class with the given name.
Returns None
if the class couldn't be allocated.
An implementation for +initialize
must also be given; the runtime calls
this method for all classes, so it must be defined on root classes.
Note that implementing a root class is not a simple endeavor.
For example, your class probably cannot be passed to Cocoa code unless
the entire NSObject
protocol is implemented.
Functionality it expects, like implementations of -retain
and -release
used by ARC, will not be present otherwise.
pub unsafe fn add_method<F>(&mut self, sel: Sel, func: F) where
F: MethodImplementation<Callee = Object>,
[src]
F: MethodImplementation<Callee = Object>,
Adds a method with the given name and implementation to self. Panics if the method wasn't sucessfully added or if the selector and function take different numbers of arguments. Unsafe because the caller must ensure that the types match those that are expected when the method is invoked from Objective-C.
pub unsafe fn add_class_method<F>(&mut self, sel: Sel, func: F) where
F: MethodImplementation<Callee = Class>,
[src]
F: MethodImplementation<Callee = Class>,
Adds a class method with the given name and implementation to self. Panics if the method wasn't sucessfully added or if the selector and function take different numbers of arguments. Unsafe because the caller must ensure that the types match those that are expected when the method is invoked from Objective-C.
pub fn add_ivar<T>(&mut self, name: &str) where
T: Encode,
[src]
T: Encode,
Adds an ivar with type T
and the provided name to self.
Panics if the ivar wasn't successfully added.
pub fn add_protocol(&mut self, proto: &Protocol)
[src]
Adds a protocol to self. Panics if the protocol wasn't successfully added
pub fn register(self) -> &'static Class
[src]
Registers self, consuming it and returning a reference to the
newly registered Class
.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,