objc2_app_kit/generated/
NSObjectController.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#[cfg(feature = "objc2-core-data")]
7#[cfg(target_vendor = "apple")]
8use objc2_core_data::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13extern_class!(
14    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsobjectcontroller?language=objc)
15    #[unsafe(super(NSController, NSObject))]
16    #[thread_kind = MainThreadOnly]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    #[cfg(feature = "NSController")]
19    pub struct NSObjectController;
20);
21
22#[cfg(feature = "NSController")]
23extern_conformance!(
24    unsafe impl NSCoding for NSObjectController {}
25);
26
27#[cfg(all(feature = "NSController", feature = "NSKeyValueBinding"))]
28extern_conformance!(
29    unsafe impl NSEditor for NSObjectController {}
30);
31
32#[cfg(all(feature = "NSController", feature = "NSKeyValueBinding"))]
33extern_conformance!(
34    unsafe impl NSEditorRegistration for NSObjectController {}
35);
36
37#[cfg(feature = "NSController")]
38extern_conformance!(
39    unsafe impl NSObjectProtocol for NSObjectController {}
40);
41
42#[cfg(feature = "NSController")]
43impl NSObjectController {
44    extern_methods!(
45        /// # Safety
46        ///
47        /// `content` should be of the correct type.
48        #[unsafe(method(initWithContent:))]
49        #[unsafe(method_family = init)]
50        pub unsafe fn initWithContent(
51            this: Allocated<Self>,
52            content: Option<&AnyObject>,
53        ) -> Retained<Self>;
54
55        /// # Safety
56        ///
57        /// `coder` possibly has further requirements.
58        #[unsafe(method(initWithCoder:))]
59        #[unsafe(method_family = init)]
60        pub unsafe fn initWithCoder(
61            this: Allocated<Self>,
62            coder: &NSCoder,
63        ) -> Option<Retained<Self>>;
64
65        #[unsafe(method(content))]
66        #[unsafe(method_family = none)]
67        pub fn content(&self) -> Option<Retained<AnyObject>>;
68
69        /// Setter for [`content`][Self::content].
70        ///
71        /// # Safety
72        ///
73        /// `content` should be of the correct type.
74        #[unsafe(method(setContent:))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn setContent(&self, content: Option<&AnyObject>);
77
78        #[unsafe(method(selection))]
79        #[unsafe(method_family = none)]
80        pub fn selection(&self) -> Retained<AnyObject>;
81
82        #[unsafe(method(selectedObjects))]
83        #[unsafe(method_family = none)]
84        pub fn selectedObjects(&self) -> Retained<NSArray>;
85
86        #[unsafe(method(automaticallyPreparesContent))]
87        #[unsafe(method_family = none)]
88        pub fn automaticallyPreparesContent(&self) -> bool;
89
90        /// Setter for [`automaticallyPreparesContent`][Self::automaticallyPreparesContent].
91        #[unsafe(method(setAutomaticallyPreparesContent:))]
92        #[unsafe(method_family = none)]
93        pub fn setAutomaticallyPreparesContent(&self, automatically_prepares_content: bool);
94
95        #[unsafe(method(prepareContent))]
96        #[unsafe(method_family = none)]
97        pub fn prepareContent(&self);
98
99        /// # Safety
100        ///
101        /// This is not retained internally, you must ensure the object is still alive.
102        #[unsafe(method(objectClass))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn objectClass(&self) -> Option<&'static AnyClass>;
105
106        /// Setter for [`objectClass`][Self::objectClass].
107        ///
108        /// # Safety
109        ///
110        /// - `object_class` probably has further requirements.
111        /// - `object_class` might not allow `None`.
112        /// - This is unretained, you must ensure the object is kept alive while in use.
113        #[unsafe(method(setObjectClass:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn setObjectClass(&self, object_class: Option<&AnyClass>);
116
117        #[unsafe(method(newObject))]
118        #[unsafe(method_family = new)]
119        pub fn newObject(&self) -> Retained<AnyObject>;
120
121        /// # Safety
122        ///
123        /// `object` should be of the correct type.
124        #[unsafe(method(addObject:))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn addObject(&self, object: &AnyObject);
127
128        /// # Safety
129        ///
130        /// `object` should be of the correct type.
131        #[unsafe(method(removeObject:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn removeObject(&self, object: &AnyObject);
134
135        #[unsafe(method(isEditable))]
136        #[unsafe(method_family = none)]
137        pub fn isEditable(&self) -> bool;
138
139        /// Setter for [`isEditable`][Self::isEditable].
140        #[unsafe(method(setEditable:))]
141        #[unsafe(method_family = none)]
142        pub fn setEditable(&self, editable: bool);
143
144        /// # Safety
145        ///
146        /// `sender` should be of the correct type.
147        #[unsafe(method(add:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn add(&self, sender: Option<&AnyObject>);
150
151        #[unsafe(method(canAdd))]
152        #[unsafe(method_family = none)]
153        pub fn canAdd(&self) -> bool;
154
155        /// # Safety
156        ///
157        /// `sender` should be of the correct type.
158        #[unsafe(method(remove:))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn remove(&self, sender: Option<&AnyObject>);
161
162        #[unsafe(method(canRemove))]
163        #[unsafe(method_family = none)]
164        pub fn canRemove(&self) -> bool;
165
166        #[cfg(feature = "NSUserInterfaceValidation")]
167        #[unsafe(method(validateUserInterfaceItem:))]
168        #[unsafe(method_family = none)]
169        pub fn validateUserInterfaceItem(
170            &self,
171            item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>,
172        ) -> bool;
173    );
174}
175
176/// Methods declared on superclass `NSController`.
177#[cfg(feature = "NSController")]
178impl NSObjectController {
179    extern_methods!(
180        #[unsafe(method(init))]
181        #[unsafe(method_family = init)]
182        pub fn init(this: Allocated<Self>) -> Retained<Self>;
183    );
184}
185
186/// Methods declared on superclass `NSObject`.
187#[cfg(feature = "NSController")]
188impl NSObjectController {
189    extern_methods!(
190        #[unsafe(method(new))]
191        #[unsafe(method_family = new)]
192        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
193    );
194}
195
196/// NSManagedController.
197#[cfg(feature = "NSController")]
198impl NSObjectController {
199    extern_methods!(
200        #[cfg(feature = "objc2-core-data")]
201        #[cfg(target_vendor = "apple")]
202        #[unsafe(method(managedObjectContext))]
203        #[unsafe(method_family = none)]
204        pub fn managedObjectContext(&self) -> Option<Retained<NSManagedObjectContext>>;
205
206        #[cfg(feature = "objc2-core-data")]
207        #[cfg(target_vendor = "apple")]
208        /// Setter for [`managedObjectContext`][Self::managedObjectContext].
209        #[unsafe(method(setManagedObjectContext:))]
210        #[unsafe(method_family = none)]
211        pub fn setManagedObjectContext(
212            &self,
213            managed_object_context: Option<&NSManagedObjectContext>,
214        );
215
216        #[unsafe(method(entityName))]
217        #[unsafe(method_family = none)]
218        pub fn entityName(&self) -> Option<Retained<NSString>>;
219
220        /// Setter for [`entityName`][Self::entityName].
221        ///
222        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
223        #[unsafe(method(setEntityName:))]
224        #[unsafe(method_family = none)]
225        pub fn setEntityName(&self, entity_name: Option<&NSString>);
226
227        #[unsafe(method(fetchPredicate))]
228        #[unsafe(method_family = none)]
229        pub fn fetchPredicate(&self) -> Option<Retained<NSPredicate>>;
230
231        /// Setter for [`fetchPredicate`][Self::fetchPredicate].
232        #[unsafe(method(setFetchPredicate:))]
233        #[unsafe(method_family = none)]
234        pub fn setFetchPredicate(&self, fetch_predicate: Option<&NSPredicate>);
235
236        #[cfg(feature = "objc2-core-data")]
237        #[cfg(target_vendor = "apple")]
238        /// # Safety
239        ///
240        /// `fetch_request` generic should be bound by `NSFetchRequestResult`.
241        #[unsafe(method(fetchWithRequest:merge:error:_))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn fetchWithRequest_merge_error(
244            &self,
245            fetch_request: Option<&NSFetchRequest>,
246            merge: bool,
247        ) -> Result<(), Retained<NSError>>;
248
249        /// # Safety
250        ///
251        /// `sender` should be of the correct type.
252        #[unsafe(method(fetch:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn fetch(&self, sender: Option<&AnyObject>);
255
256        #[unsafe(method(usesLazyFetching))]
257        #[unsafe(method_family = none)]
258        pub fn usesLazyFetching(&self) -> bool;
259
260        /// Setter for [`usesLazyFetching`][Self::usesLazyFetching].
261        #[unsafe(method(setUsesLazyFetching:))]
262        #[unsafe(method_family = none)]
263        pub fn setUsesLazyFetching(&self, uses_lazy_fetching: bool);
264
265        #[cfg(feature = "objc2-core-data")]
266        #[cfg(target_vendor = "apple")]
267        #[unsafe(method(defaultFetchRequest))]
268        #[unsafe(method_family = none)]
269        pub fn defaultFetchRequest(&self) -> Retained<NSFetchRequest>;
270    );
271}