Crate objc [−] [src]
Objective-C Runtime bindings and wrapper for Rust.
Messaging objects
Objective-C objects can be messaged using the msg_send! macro:
let cls = Class::get("NSObject").unwrap(); let obj: *mut Object = msg_send![cls, new]; let hash: usize = msg_send![obj, hash]; let is_kind: BOOL = msg_send![obj, isKindOfClass:cls]; // Even void methods must have their return type annotated let _: () = msg_send![obj, release];
Declaring classes
Objective-C classes can even be declared from Rust using the functionality of
the declare module.
Exceptions
By default, if the msg_send! macro causes an exception to be thrown, this
will unwind into Rust resulting in unsafe, undefined behavior.
However, this crate has an "exception" feature which, when enabled, wraps
each msg_send! in a @try/@catch and panics if an exception is caught,
preventing Objective-C from unwinding into Rust.
Modules
| declare |
Functionality for declaring Objective-C classes. |
| runtime |
A Rust interface for the functionality of the Objective-C runtime. |
Macros
| msg_send! |
Sends a message to an object. |
| sel! |
Registers a selector, returning a |
Structs
| Encoding |
An Objective-C type encoding. |
Traits
| Encode |
Types that have an Objective-C type encoding. |
| Message |
Types that may be sent Objective-C messages. For example: objects, classes, and blocks. |
| MessageArguments |
Types that may be used as the arguments of an Objective-C message. |