@@ -9,27 +9,30 @@ use objc2::{declare_class, extern_class, msg_send, msg_send_id, ClassType};
99extern "C" { }
1010
1111#[ cfg( all( feature = "apple" , target_os = "macos" ) ) ]
12- extern_class ! {
13- unsafe struct NSResponder : NSObject ;
14- }
12+ extern_class ! (
13+ struct NSResponder ;
14+
15+ unsafe impl ClassType for NSResponder {
16+ type Superclass = NSObject ;
17+ }
18+ ) ;
1519
1620#[ cfg( all( feature = "apple" , target_os = "macos" ) ) ]
17- declare_class ! {
18- unsafe struct CustomAppDelegate : NSResponder , NSObject {
21+ declare_class ! (
22+ struct CustomAppDelegate {
1923 pub ivar: u8 ,
2024 another_ivar: Bool ,
2125 }
2226
23- unsafe impl {
27+ unsafe impl ClassType for CustomAppDelegate {
28+ #[ inherits( NSObject ) ]
29+ type Superclass = NSResponder ;
30+ }
31+
32+ unsafe impl CustomAppDelegate {
2433 #[ sel( initWith: another: ) ]
25- fn init_with(
26- self : & mut Self ,
27- ivar: u8 ,
28- another_ivar: Bool ,
29- ) -> * mut Self {
30- let this: * mut Self = unsafe {
31- msg_send![ super ( self , NSResponder :: class( ) ) , init]
32- } ;
34+ fn init_with( self : & mut Self , ivar: u8 , another_ivar: Bool ) -> * mut Self {
35+ let this: * mut Self = unsafe { msg_send![ super ( self , NSResponder :: class( ) ) , init] } ;
3336 if let Some ( this) = unsafe { this. as_mut( ) } {
3437 // TODO: Allow initialization through MaybeUninit
3538 * this. ivar = ivar;
@@ -49,7 +52,7 @@ declare_class! {
4952 // `clang` only when used in Objective-C...
5053 //
5154 // TODO: Investigate this!
52- unsafe impl {
55+ unsafe impl CustomAppDelegate {
5356 /// This is `unsafe` because it expects `sender` to be valid
5457 #[ sel( applicationDidFinishLaunching: ) ]
5558 unsafe fn did_finish_launching( & self , sender: * mut Object ) {
@@ -65,7 +68,7 @@ declare_class! {
6568 println!( "Will terminate!" ) ;
6669 }
6770 }
68- }
71+ ) ;
6972
7073#[ cfg( all( feature = "apple" , target_os = "macos" ) ) ]
7174impl CustomAppDelegate {
0 commit comments