[−][src]Macro rubrail::objc_subclass
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
-
$newclass
- Name of the new Obj-C class to create -
$superclass
- Name of the existing Obj-C class to wrap -
$unique_newclass
- Any unique variable name that is different from $newclass. This is just used to manage one-time initialization, and is manual becauseconcat_idents!()
is unstable.
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]; } }