objc2_foundation/generated/
NSNotification.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnotificationname?language=objc)
10// NS_TYPED_EXTENSIBLE_ENUM
11#[cfg(feature = "NSString")]
12pub type NSNotificationName = NSString;
13
14extern_class!(
15    /// **************    Notifications    ***************
16    ///
17    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnotification?language=objc)
18    #[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 unsafe fn name(&self) -> Retained<NSNotificationName>;
48
49        #[unsafe(method(object))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn object(&self) -> Option<Retained<AnyObject>>;
52
53        #[cfg(feature = "NSDictionary")]
54        #[unsafe(method(userInfo))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn userInfo(&self) -> Option<Retained<NSDictionary>>;
57
58        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
59        #[unsafe(method(initWithName:object:userInfo:))]
60        #[unsafe(method_family = init)]
61        pub unsafe fn initWithName_object_userInfo(
62            this: Allocated<Self>,
63            name: &NSNotificationName,
64            object: Option<&AnyObject>,
65            user_info: Option<&NSDictionary>,
66        ) -> Retained<Self>;
67
68        #[cfg(feature = "NSCoder")]
69        #[unsafe(method(initWithCoder:))]
70        #[unsafe(method_family = init)]
71        pub unsafe fn initWithCoder(
72            this: Allocated<Self>,
73            coder: &NSCoder,
74        ) -> Option<Retained<Self>>;
75    );
76}
77
78/// NSNotificationCreation.
79impl NSNotification {
80    extern_methods!(
81        #[cfg(feature = "NSString")]
82        #[unsafe(method(notificationWithName:object:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn notificationWithName_object(
85            a_name: &NSNotificationName,
86            an_object: Option<&AnyObject>,
87        ) -> Retained<Self>;
88
89        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
90        #[unsafe(method(notificationWithName:object:userInfo:))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn notificationWithName_object_userInfo(
93            a_name: &NSNotificationName,
94            an_object: Option<&AnyObject>,
95            a_user_info: Option<&NSDictionary>,
96        ) -> Retained<Self>;
97    );
98}
99
100extern_class!(
101    /// **************    Notification Center    ***************
102    ///
103    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnotificationcenter?language=objc)
104    #[unsafe(super(NSObject))]
105    #[derive(Debug, PartialEq, Eq, Hash)]
106    pub struct NSNotificationCenter;
107);
108
109unsafe impl Send for NSNotificationCenter {}
110
111unsafe impl Sync for NSNotificationCenter {}
112
113extern_conformance!(
114    unsafe impl NSObjectProtocol for NSNotificationCenter {}
115);
116
117impl NSNotificationCenter {
118    extern_methods!(
119        #[unsafe(method(defaultCenter))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn defaultCenter() -> Retained<NSNotificationCenter>;
122
123        #[cfg(feature = "NSString")]
124        #[unsafe(method(addObserver:selector:name:object:))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn addObserver_selector_name_object(
127            &self,
128            observer: &AnyObject,
129            a_selector: Sel,
130            a_name: Option<&NSNotificationName>,
131            an_object: Option<&AnyObject>,
132        );
133
134        #[unsafe(method(postNotification:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn postNotification(&self, notification: &NSNotification);
137
138        #[cfg(feature = "NSString")]
139        #[unsafe(method(postNotificationName:object:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn postNotificationName_object(
142            &self,
143            a_name: &NSNotificationName,
144            an_object: Option<&AnyObject>,
145        );
146
147        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
148        #[unsafe(method(postNotificationName:object:userInfo:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn postNotificationName_object_userInfo(
151            &self,
152            a_name: &NSNotificationName,
153            an_object: Option<&AnyObject>,
154            a_user_info: Option<&NSDictionary>,
155        );
156
157        #[unsafe(method(removeObserver:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn removeObserver(&self, observer: &AnyObject);
160
161        #[cfg(feature = "NSString")]
162        #[unsafe(method(removeObserver:name:object:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn removeObserver_name_object(
165            &self,
166            observer: &AnyObject,
167            a_name: Option<&NSNotificationName>,
168            an_object: Option<&AnyObject>,
169        );
170
171        #[cfg(all(feature = "NSOperation", feature = "NSString", feature = "block2"))]
172        #[unsafe(method(addObserverForName:object:queue:usingBlock:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn addObserverForName_object_queue_usingBlock(
175            &self,
176            name: Option<&NSNotificationName>,
177            obj: Option<&AnyObject>,
178            queue: Option<&NSOperationQueue>,
179            block: &block2::DynBlock<dyn Fn(NonNull<NSNotification>)>,
180        ) -> Retained<ProtocolObject<dyn NSObjectProtocol>>;
181    );
182}
183
184/// Methods declared on superclass `NSObject`.
185impl NSNotificationCenter {
186    extern_methods!(
187        #[unsafe(method(init))]
188        #[unsafe(method_family = init)]
189        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
190
191        #[unsafe(method(new))]
192        #[unsafe(method_family = new)]
193        pub unsafe fn new() -> Retained<Self>;
194    );
195}