Closed mdenty closed 1 year ago
Add this to lib.rs
:
#[macro_use]
extern crate objc;
Thank you very much for the quick answer. I suppose this should be in the documentation of the base example to avoid such basic question of noobs like me.
The working code in my main.rs
is
#[macro_use]
extern crate objc;
use objc::{class, msg_send};
use objc::runtime::{BOOL, Object};
fn main() {
println!("Hello, world!");
unsafe {
let cls = class!(NSObject);
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];
println!("{hash}: {is_kind}");
}
}
The errors are :