1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;

use crate::*;

// NS_TYPED_EXTENSIBLE_ENUM
#[cfg(feature = "NSString")]
pub type NSNotificationName = NSString;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSNotification;

    unsafe impl ClassType for NSNotification {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

#[cfg(feature = "NSObject")]
unsafe impl NSCoding for NSNotification {}

#[cfg(feature = "NSObject")]
unsafe impl NSCopying for NSNotification {}

unsafe impl NSObjectProtocol for NSNotification {}

extern_methods!(
    unsafe impl NSNotification {
        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other name)]
        pub unsafe fn name(&self) -> Retained<NSNotificationName>;

        #[method_id(@__retain_semantics Other object)]
        pub unsafe fn object(&self) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSDictionary")]
        #[method_id(@__retain_semantics Other userInfo)]
        pub unsafe fn userInfo(&self) -> Option<Retained<NSDictionary>>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method_id(@__retain_semantics Init initWithName:object:userInfo:)]
        pub unsafe fn initWithName_object_userInfo(
            this: Allocated<Self>,
            name: &NSNotificationName,
            object: Option<&AnyObject>,
            user_info: Option<&NSDictionary>,
        ) -> Retained<Self>;

        #[cfg(feature = "NSCoder")]
        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;
    }
);

extern_methods!(
    /// NSNotificationCreation
    unsafe impl NSNotification {
        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other notificationWithName:object:)]
        pub unsafe fn notificationWithName_object(
            a_name: &NSNotificationName,
            an_object: Option<&AnyObject>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method_id(@__retain_semantics Other notificationWithName:object:userInfo:)]
        pub unsafe fn notificationWithName_object_userInfo(
            a_name: &NSNotificationName,
            an_object: Option<&AnyObject>,
            a_user_info: Option<&NSDictionary>,
        ) -> Retained<Self>;
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSNotificationCenter;

    unsafe impl ClassType for NSNotificationCenter {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl Send for NSNotificationCenter {}

unsafe impl Sync for NSNotificationCenter {}

unsafe impl NSObjectProtocol for NSNotificationCenter {}

extern_methods!(
    unsafe impl NSNotificationCenter {
        #[method_id(@__retain_semantics Other defaultCenter)]
        pub unsafe fn defaultCenter() -> Retained<NSNotificationCenter>;

        #[cfg(feature = "NSString")]
        #[method(addObserver:selector:name:object:)]
        pub unsafe fn addObserver_selector_name_object(
            &self,
            observer: &AnyObject,
            a_selector: Sel,
            a_name: Option<&NSNotificationName>,
            an_object: Option<&AnyObject>,
        );

        #[method(postNotification:)]
        pub unsafe fn postNotification(&self, notification: &NSNotification);

        #[cfg(feature = "NSString")]
        #[method(postNotificationName:object:)]
        pub unsafe fn postNotificationName_object(
            &self,
            a_name: &NSNotificationName,
            an_object: Option<&AnyObject>,
        );

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method(postNotificationName:object:userInfo:)]
        pub unsafe fn postNotificationName_object_userInfo(
            &self,
            a_name: &NSNotificationName,
            an_object: Option<&AnyObject>,
            a_user_info: Option<&NSDictionary>,
        );

        #[method(removeObserver:)]
        pub unsafe fn removeObserver(&self, observer: &AnyObject);

        #[cfg(feature = "NSString")]
        #[method(removeObserver:name:object:)]
        pub unsafe fn removeObserver_name_object(
            &self,
            observer: &AnyObject,
            a_name: Option<&NSNotificationName>,
            an_object: Option<&AnyObject>,
        );

        #[cfg(all(feature = "NSOperation", feature = "NSString", feature = "block2"))]
        #[method_id(@__retain_semantics Other addObserverForName:object:queue:usingBlock:)]
        pub unsafe fn addObserverForName_object_queue_usingBlock(
            &self,
            name: Option<&NSNotificationName>,
            obj: Option<&AnyObject>,
            queue: Option<&NSOperationQueue>,
            block: &block2::Block<dyn Fn(NonNull<NSNotification>)>,
        ) -> Retained<NSObject>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSNotificationCenter {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);