docs

你正在阅读 v0.1.2 的文档。Nabi 0.1.2 已不再提供支持。 最新版本:v0.1.3 →

bare::ffi::objc::subclass

本页内容

API 参考只有英文版,由标准库源代码中的英文文档注释生成。

classes made at run time (objc_allocateClassPair): Nabi functions as an Objective-C class's methods, for delegates and the classes an API wants subclassed.

A method's implementation is an extern "C" fn(this: CPtr<u8>, cmd: Sel, ..) with the arguments its selector takes; types is its Objective-C type encoding ("v@:@": returns void, takes self, _cmd and an object).

Structs

ClassBuilderSource

pub struct ClassBuilder

A class being made: add its methods and protocols, then register.

  • pub fn new(name: str, sup: Class) -> ClassBuilder | none§

    Source

    A new class name whose superclass is sup; none when a class of that name exists.

  • pub unsafe fn method(self, sel: Sel, imp: usize, types: str) -> ClassBuilder§

    Source

    Method sel running imp, the address of an extern "C" fn taking the receiver, the selector and sel's arguments, of type encoding types. A method of the superclass it overrides must have its signature.

    Safety: imp is such a function, and types says its signature.

  • pub fn protocol(self, name: str) -> ClassBuilder§

    Source

    Conform to protocol name (NSApplicationDelegate), which a linked framework declares.

  • pub fn register(self) -> Class§

    Source

    Register the class with the runtime; its class object, whose alloc/new make instances.