objc2_foundation/generated/
NSNotification.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[cfg(feature = "NSString")]
12pub type NSNotificationName = NSString;
13
14extern_class!(
15 #[unsafe(super(NSObject))]
19 #[derive(Debug, PartialEq, Eq, Hash)]
20 pub struct NSNotification;
21);
22
23#[cfg(feature = "NSObject")]
24unsafe impl NSCoding for NSNotification {}
25
26#[cfg(feature = "NSObject")]
27unsafe impl NSCopying for NSNotification {}
28
29#[cfg(feature = "NSObject")]
30unsafe impl CopyingHelper for NSNotification {
31 type Result = Self;
32}
33
34unsafe impl NSObjectProtocol for NSNotification {}
35
36impl NSNotification {
37 extern_methods!(
38 #[cfg(feature = "NSString")]
39 #[unsafe(method(name))]
40 #[unsafe(method_family = none)]
41 pub unsafe fn name(&self) -> Retained<NSNotificationName>;
42
43 #[unsafe(method(object))]
44 #[unsafe(method_family = none)]
45 pub unsafe fn object(&self) -> Option<Retained<AnyObject>>;
46
47 #[cfg(feature = "NSDictionary")]
48 #[unsafe(method(userInfo))]
49 #[unsafe(method_family = none)]
50 pub unsafe fn userInfo(&self) -> Option<Retained<NSDictionary>>;
51
52 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
53 #[unsafe(method(initWithName:object:userInfo:))]
54 #[unsafe(method_family = init)]
55 pub unsafe fn initWithName_object_userInfo(
56 this: Allocated<Self>,
57 name: &NSNotificationName,
58 object: Option<&AnyObject>,
59 user_info: Option<&NSDictionary>,
60 ) -> Retained<Self>;
61
62 #[cfg(feature = "NSCoder")]
63 #[unsafe(method(initWithCoder:))]
64 #[unsafe(method_family = init)]
65 pub unsafe fn initWithCoder(
66 this: Allocated<Self>,
67 coder: &NSCoder,
68 ) -> Option<Retained<Self>>;
69 );
70}
71
72impl NSNotification {
74 extern_methods!(
75 #[cfg(feature = "NSString")]
76 #[unsafe(method(notificationWithName:object:))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn notificationWithName_object(
79 a_name: &NSNotificationName,
80 an_object: Option<&AnyObject>,
81 ) -> Retained<Self>;
82
83 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
84 #[unsafe(method(notificationWithName:object:userInfo:))]
85 #[unsafe(method_family = none)]
86 pub unsafe fn notificationWithName_object_userInfo(
87 a_name: &NSNotificationName,
88 an_object: Option<&AnyObject>,
89 a_user_info: Option<&NSDictionary>,
90 ) -> Retained<Self>;
91 );
92}
93
94extern_class!(
95 #[unsafe(super(NSObject))]
99 #[derive(Debug, PartialEq, Eq, Hash)]
100 pub struct NSNotificationCenter;
101);
102
103unsafe impl Send for NSNotificationCenter {}
104
105unsafe impl Sync for NSNotificationCenter {}
106
107unsafe impl NSObjectProtocol for NSNotificationCenter {}
108
109impl NSNotificationCenter {
110 extern_methods!(
111 #[unsafe(method(defaultCenter))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn defaultCenter() -> Retained<NSNotificationCenter>;
114
115 #[cfg(feature = "NSString")]
116 #[unsafe(method(addObserver:selector:name:object:))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn addObserver_selector_name_object(
119 &self,
120 observer: &AnyObject,
121 a_selector: Sel,
122 a_name: Option<&NSNotificationName>,
123 an_object: Option<&AnyObject>,
124 );
125
126 #[unsafe(method(postNotification:))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn postNotification(&self, notification: &NSNotification);
129
130 #[cfg(feature = "NSString")]
131 #[unsafe(method(postNotificationName:object:))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn postNotificationName_object(
134 &self,
135 a_name: &NSNotificationName,
136 an_object: Option<&AnyObject>,
137 );
138
139 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
140 #[unsafe(method(postNotificationName:object:userInfo:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn postNotificationName_object_userInfo(
143 &self,
144 a_name: &NSNotificationName,
145 an_object: Option<&AnyObject>,
146 a_user_info: Option<&NSDictionary>,
147 );
148
149 #[unsafe(method(removeObserver:))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn removeObserver(&self, observer: &AnyObject);
152
153 #[cfg(feature = "NSString")]
154 #[unsafe(method(removeObserver:name:object:))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn removeObserver_name_object(
157 &self,
158 observer: &AnyObject,
159 a_name: Option<&NSNotificationName>,
160 an_object: Option<&AnyObject>,
161 );
162
163 #[cfg(all(feature = "NSOperation", feature = "NSString", feature = "block2"))]
164 #[unsafe(method(addObserverForName:object:queue:usingBlock:))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn addObserverForName_object_queue_usingBlock(
167 &self,
168 name: Option<&NSNotificationName>,
169 obj: Option<&AnyObject>,
170 queue: Option<&NSOperationQueue>,
171 block: &block2::Block<dyn Fn(NonNull<NSNotification>)>,
172 ) -> Retained<ProtocolObject<dyn NSObjectProtocol>>;
173 );
174}
175
176impl NSNotificationCenter {
178 extern_methods!(
179 #[unsafe(method(init))]
180 #[unsafe(method_family = init)]
181 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
182
183 #[unsafe(method(new))]
184 #[unsafe(method_family = new)]
185 pub unsafe fn new() -> Retained<Self>;
186 );
187}