MCPcopy Create free account
hub / github.com/SSheldon/rust-objc / root

Method root

src/declare.rs:151–160  ·  view source on GitHub ↗

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

(name: &str, intitialize_fn: extern fn(&Class, Sel))

Source from the content-addressed store, hash-verified

149 used by ARC, will not be present otherwise.
150 */
151 pub fn root(name: &str, intitialize_fn: extern fn(&Class, Sel))
152 -> Option<ClassDecl> {
153 let mut decl = ClassDecl::with_superclass(name, None);
154 if let Some(ref mut decl) = decl {
155 unsafe {
156 decl.add_class_method(sel!(initialize), intitialize_fn);
157 }
158 }
159 decl
160 }
161
162 /// Adds a method with the given name and implementation to self.
163 /// Panics if the method wasn't sucessfully added

Callers

nothing calls this directly

Calls 1

add_class_methodMethod · 0.80

Tested by

no test coverage detected