[][src]Macro rubrail::objc_subclass

macro_rules! objc_subclass {
    ( $newclass:ident, $superclass:ident, $unique_newclass:ident ) => { ... };
}

Wrap an Objective-C class in a subclass that tracks allocations

This creates an Objective-C wrapper class which can be used during development to print or set breakpoints on object retain, release, or dealloc of certain Obj-C objects.

Enable by compiling with the objc_wrapper feature. By default it only adds printing when an object deallocation begins, and provides nice places to hook breakpoints with lldb.

Arguments

Example

#[macro_use]
extern crate rubrail;
#[macro_use]
extern crate objc;
use objc::runtime::Class;
use objc::runtime::Object;

fn main() {
  objc_subclass!(MyNSObject, NSObject, MYNSOBJECT_CLASS);
  let cls = MyNSObject::class();
  unsafe {
    let obj: *mut Object = msg_send![cls, alloc];
    let obj: *mut Object = msg_send![obj, init];
  }
}