diff --git a/crates/objc2/src/declare/ivar.rs b/crates/objc2/src/declare/ivar.rs index d9dbedd74..0a229edb7 100644 --- a/crates/objc2/src/declare/ivar.rs +++ b/crates/objc2/src/declare/ivar.rs @@ -348,10 +348,14 @@ mod tests { #[test] fn access_ivar() { + std::println!("create"); let mut obj = test_utils::custom_object(); + std::println!("setFoo"); let _: () = unsafe { msg_send![&mut obj, setFoo: 42u32] }; + std::println!("convert"); let obj = unsafe { Id::as_ptr(&obj).cast::().as_ref().unwrap() }; + std::println!("access"); assert_eq!(*obj.foo, 42); } diff --git a/crates/objc2/src/test_utils.rs b/crates/objc2/src/test_utils.rs index f8ca1d897..97d975326 100644 --- a/crates/objc2/src/test_utils.rs +++ b/crates/objc2/src/test_utils.rs @@ -72,8 +72,11 @@ pub(crate) fn custom_class() -> &'static AnyClass { static REGISTER_CUSTOM_CLASS: Once = Once::new(); REGISTER_CUSTOM_CLASS.call_once(|| { + std::println!("register class"); // The runtime will call this method, so it has to be implemented - extern "C" fn custom_obj_class_initialize(_this: &AnyClass, _cmd: Sel) {} + extern "C" fn custom_obj_class_initialize(_this: &AnyClass, _cmd: Sel) { + std::println!("init class"); + } let mut builder = ClassBuilder::root( "CustomObject", @@ -86,6 +89,7 @@ pub(crate) fn custom_class() -> &'static AnyClass { builder.add_ivar::("_foo"); unsafe extern "C" fn custom_obj_release(this: *mut AnyObject, _cmd: Sel) { + std::println!("release class"); unsafe { #[allow(deprecated)] ffi::object_dispose(this.cast()); @@ -184,6 +188,7 @@ pub(crate) fn custom_class() -> &'static AnyClass { builder.register(); }); + std::println!("get class"); // Can't use `class!` here since `CustomObject` is dynamically created. AnyClass::get("CustomObject").unwrap() }