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")]
24extern_conformance!(
25 unsafe impl NSCoding for NSNotification {}
26);
27
28#[cfg(feature = "NSObject")]
29extern_conformance!(
30 unsafe impl NSCopying for NSNotification {}
31);
32
33#[cfg(feature = "NSObject")]
34unsafe impl CopyingHelper for NSNotification {
35 type Result = Self;
36}
37
38extern_conformance!(
39 unsafe impl NSObjectProtocol for NSNotification {}
40);
41
42impl NSNotification {
43 extern_methods!(
44 #[cfg(feature = "NSString")]
45 #[unsafe(method(name))]
46 #[unsafe(method_family = none)]
47 pub fn name(&self) -> Retained<NSNotificationName>;
48
49 #[unsafe(method(object))]
50 #[unsafe(method_family = none)]
51 pub fn object(&self) -> Option<Retained<AnyObject>>;
52
53 #[cfg(feature = "NSDictionary")]
54 #[unsafe(method(userInfo))]
55 #[unsafe(method_family = none)]
56 pub fn userInfo(&self) -> Option<Retained<NSDictionary>>;
57
58 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
59 #[unsafe(method(initWithName:object:userInfo:))]
64 #[unsafe(method_family = init)]
65 pub unsafe fn initWithName_object_userInfo(
66 this: Allocated<Self>,
67 name: &NSNotificationName,
68 object: Option<&AnyObject>,
69 user_info: Option<&NSDictionary>,
70 ) -> Retained<Self>;
71
72 #[cfg(feature = "NSCoder")]
73 #[unsafe(method(initWithCoder:))]
77 #[unsafe(method_family = init)]
78 pub unsafe fn initWithCoder(
79 this: Allocated<Self>,
80 coder: &NSCoder,
81 ) -> Option<Retained<Self>>;
82 );
83}
84
85impl NSNotification {
87 extern_methods!(
88 #[cfg(feature = "NSString")]
89 #[unsafe(method(notificationWithName:object:))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn notificationWithName_object(
95 a_name: &NSNotificationName,
96 an_object: Option<&AnyObject>,
97 ) -> Retained<Self>;
98
99 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
100 #[unsafe(method(notificationWithName:object:userInfo:))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn notificationWithName_object_userInfo(
107 a_name: &NSNotificationName,
108 an_object: Option<&AnyObject>,
109 a_user_info: Option<&NSDictionary>,
110 ) -> Retained<Self>;
111 );
112}
113
114extern_class!(
115 #[unsafe(super(NSObject))]
119 #[derive(Debug, PartialEq, Eq, Hash)]
120 pub struct NSNotificationCenter;
121);
122
123unsafe impl Send for NSNotificationCenter {}
124
125unsafe impl Sync for NSNotificationCenter {}
126
127extern_conformance!(
128 unsafe impl NSObjectProtocol for NSNotificationCenter {}
129);
130
131impl NSNotificationCenter {
132 extern_methods!(
133 #[unsafe(method(defaultCenter))]
134 #[unsafe(method_family = none)]
135 pub fn defaultCenter() -> Retained<NSNotificationCenter>;
136
137 #[cfg(feature = "NSString")]
138 #[unsafe(method(addObserver:selector:name:object:))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn addObserver_selector_name_object(
146 &self,
147 observer: &AnyObject,
148 a_selector: Sel,
149 a_name: Option<&NSNotificationName>,
150 an_object: Option<&AnyObject>,
151 );
152
153 #[unsafe(method(postNotification:))]
154 #[unsafe(method_family = none)]
155 pub fn postNotification(&self, notification: &NSNotification);
156
157 #[cfg(feature = "NSString")]
158 #[unsafe(method(postNotificationName:object:))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn postNotificationName_object(
164 &self,
165 a_name: &NSNotificationName,
166 an_object: Option<&AnyObject>,
167 );
168
169 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
170 #[unsafe(method(postNotificationName:object:userInfo:))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn postNotificationName_object_userInfo(
177 &self,
178 a_name: &NSNotificationName,
179 an_object: Option<&AnyObject>,
180 a_user_info: Option<&NSDictionary>,
181 );
182
183 #[unsafe(method(removeObserver:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn removeObserver(&self, observer: &AnyObject);
189
190 #[cfg(feature = "NSString")]
191 #[unsafe(method(removeObserver:name:object:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn removeObserver_name_object(
198 &self,
199 observer: &AnyObject,
200 a_name: Option<&NSNotificationName>,
201 an_object: Option<&AnyObject>,
202 );
203
204 #[cfg(all(feature = "NSOperation", feature = "NSString", feature = "block2"))]
205 #[unsafe(method(addObserverForName:object:queue:usingBlock:))]
211 #[unsafe(method_family = none)]
212 pub unsafe fn addObserverForName_object_queue_usingBlock(
213 &self,
214 name: Option<&NSNotificationName>,
215 obj: Option<&AnyObject>,
216 queue: Option<&NSOperationQueue>,
217 block: &block2::DynBlock<dyn Fn(NonNull<NSNotification>)>,
218 ) -> Retained<ProtocolObject<dyn NSObjectProtocol>>;
219 );
220}
221
222impl NSNotificationCenter {
224 extern_methods!(
225 #[unsafe(method(init))]
226 #[unsafe(method_family = init)]
227 pub fn init(this: Allocated<Self>) -> Retained<Self>;
228
229 #[unsafe(method(new))]
230 #[unsafe(method_family = new)]
231 pub fn new() -> Retained<Self>;
232 );
233}
234
235impl DefaultRetained for NSNotificationCenter {
236 #[inline]
237 fn default_retained() -> Retained<Self> {
238 Self::new()
239 }
240}