objc2_foundation/generated/
NSBundle.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9pub const NSBundleExecutableArchitectureI386: c_uint = 0x00000007;
11pub const NSBundleExecutableArchitecturePPC: c_uint = 0x00000012;
13pub const NSBundleExecutableArchitectureX86_64: c_uint = 0x01000007;
15pub const NSBundleExecutableArchitecturePPC64: c_uint = 0x01000012;
17pub const NSBundleExecutableArchitectureARM64: c_uint = 0x0100000c;
19
20extern_class!(
21 #[unsafe(super(NSObject))]
23 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub struct NSBundle;
25);
26
27unsafe impl Send for NSBundle {}
28
29unsafe impl Sync for NSBundle {}
30
31extern_conformance!(
32 unsafe impl NSObjectProtocol for NSBundle {}
33);
34
35impl NSBundle {
36 extern_methods!(
37 #[unsafe(method(mainBundle))]
38 #[unsafe(method_family = none)]
39 pub fn mainBundle() -> Retained<NSBundle>;
40
41 #[cfg(feature = "NSString")]
42 #[unsafe(method(bundleWithPath:))]
43 #[unsafe(method_family = none)]
44 pub fn bundleWithPath(path: &NSString) -> Option<Retained<Self>>;
45
46 #[cfg(feature = "NSString")]
47 #[unsafe(method(initWithPath:))]
48 #[unsafe(method_family = init)]
49 pub fn initWithPath(this: Allocated<Self>, path: &NSString) -> Option<Retained<Self>>;
50
51 #[cfg(feature = "NSURL")]
52 #[unsafe(method(bundleWithURL:))]
53 #[unsafe(method_family = none)]
54 pub fn bundleWithURL(url: &NSURL) -> Option<Retained<Self>>;
55
56 #[cfg(feature = "NSURL")]
57 #[unsafe(method(initWithURL:))]
58 #[unsafe(method_family = init)]
59 pub fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;
60
61 #[unsafe(method(bundleForClass:))]
65 #[unsafe(method_family = none)]
66 pub unsafe fn bundleForClass(a_class: &AnyClass) -> Retained<NSBundle>;
67
68 #[cfg(feature = "NSString")]
69 #[unsafe(method(bundleWithIdentifier:))]
70 #[unsafe(method_family = none)]
71 pub fn bundleWithIdentifier(identifier: &NSString) -> Option<Retained<NSBundle>>;
72
73 #[cfg(feature = "NSArray")]
74 #[unsafe(method(allBundles))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn allBundles() -> Retained<NSArray<NSBundle>>;
77
78 #[cfg(feature = "NSArray")]
79 #[unsafe(method(allFrameworks))]
80 #[unsafe(method_family = none)]
81 pub unsafe fn allFrameworks() -> Retained<NSArray<NSBundle>>;
82
83 #[unsafe(method(load))]
84 #[unsafe(method_family = none)]
85 pub unsafe fn load(&self) -> bool;
86
87 #[unsafe(method(isLoaded))]
88 #[unsafe(method_family = none)]
89 pub fn isLoaded(&self) -> bool;
90
91 #[unsafe(method(unload))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn unload(&self) -> bool;
94
95 #[cfg(feature = "NSError")]
96 #[unsafe(method(preflightAndReturnError:_))]
97 #[unsafe(method_family = none)]
98 pub fn preflightAndReturnError(&self) -> Result<(), Retained<NSError>>;
99
100 #[cfg(feature = "NSError")]
101 #[unsafe(method(loadAndReturnError:_))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn loadAndReturnError(&self) -> Result<(), Retained<NSError>>;
104
105 #[cfg(feature = "NSURL")]
106 #[unsafe(method(bundleURL))]
107 #[unsafe(method_family = none)]
108 pub fn bundleURL(&self) -> Retained<NSURL>;
109
110 #[cfg(feature = "NSURL")]
111 #[unsafe(method(resourceURL))]
112 #[unsafe(method_family = none)]
113 pub fn resourceURL(&self) -> Option<Retained<NSURL>>;
114
115 #[cfg(feature = "NSURL")]
116 #[unsafe(method(executableURL))]
117 #[unsafe(method_family = none)]
118 pub fn executableURL(&self) -> Option<Retained<NSURL>>;
119
120 #[cfg(all(feature = "NSString", feature = "NSURL"))]
121 #[unsafe(method(URLForAuxiliaryExecutable:))]
122 #[unsafe(method_family = none)]
123 pub fn URLForAuxiliaryExecutable(
124 &self,
125 executable_name: &NSString,
126 ) -> Option<Retained<NSURL>>;
127
128 #[cfg(feature = "NSURL")]
129 #[unsafe(method(privateFrameworksURL))]
130 #[unsafe(method_family = none)]
131 pub fn privateFrameworksURL(&self) -> Option<Retained<NSURL>>;
132
133 #[cfg(feature = "NSURL")]
134 #[unsafe(method(sharedFrameworksURL))]
135 #[unsafe(method_family = none)]
136 pub fn sharedFrameworksURL(&self) -> Option<Retained<NSURL>>;
137
138 #[cfg(feature = "NSURL")]
139 #[unsafe(method(sharedSupportURL))]
140 #[unsafe(method_family = none)]
141 pub fn sharedSupportURL(&self) -> Option<Retained<NSURL>>;
142
143 #[cfg(feature = "NSURL")]
144 #[unsafe(method(builtInPlugInsURL))]
145 #[unsafe(method_family = none)]
146 pub fn builtInPlugInsURL(&self) -> Option<Retained<NSURL>>;
147
148 #[cfg(feature = "NSURL")]
149 #[unsafe(method(appStoreReceiptURL))]
150 #[unsafe(method_family = none)]
151 pub fn appStoreReceiptURL(&self) -> Option<Retained<NSURL>>;
152
153 #[cfg(feature = "NSString")]
154 #[unsafe(method(bundlePath))]
155 #[unsafe(method_family = none)]
156 pub fn bundlePath(&self) -> Retained<NSString>;
157
158 #[cfg(feature = "NSString")]
159 #[unsafe(method(resourcePath))]
160 #[unsafe(method_family = none)]
161 pub fn resourcePath(&self) -> Option<Retained<NSString>>;
162
163 #[cfg(feature = "NSString")]
164 #[unsafe(method(executablePath))]
165 #[unsafe(method_family = none)]
166 pub fn executablePath(&self) -> Option<Retained<NSString>>;
167
168 #[cfg(feature = "NSString")]
169 #[unsafe(method(pathForAuxiliaryExecutable:))]
170 #[unsafe(method_family = none)]
171 pub fn pathForAuxiliaryExecutable(
172 &self,
173 executable_name: &NSString,
174 ) -> Option<Retained<NSString>>;
175
176 #[cfg(feature = "NSString")]
177 #[unsafe(method(privateFrameworksPath))]
178 #[unsafe(method_family = none)]
179 pub fn privateFrameworksPath(&self) -> Option<Retained<NSString>>;
180
181 #[cfg(feature = "NSString")]
182 #[unsafe(method(sharedFrameworksPath))]
183 #[unsafe(method_family = none)]
184 pub fn sharedFrameworksPath(&self) -> Option<Retained<NSString>>;
185
186 #[cfg(feature = "NSString")]
187 #[unsafe(method(sharedSupportPath))]
188 #[unsafe(method_family = none)]
189 pub fn sharedSupportPath(&self) -> Option<Retained<NSString>>;
190
191 #[cfg(feature = "NSString")]
192 #[unsafe(method(builtInPlugInsPath))]
193 #[unsafe(method_family = none)]
194 pub fn builtInPlugInsPath(&self) -> Option<Retained<NSString>>;
195
196 #[cfg(all(feature = "NSString", feature = "NSURL"))]
197 #[unsafe(method(URLForResource:withExtension:subdirectory:inBundleWithURL:))]
198 #[unsafe(method_family = none)]
199 pub fn URLForResource_withExtension_subdirectory_inBundleWithURL(
200 name: Option<&NSString>,
201 ext: Option<&NSString>,
202 subpath: Option<&NSString>,
203 bundle_url: &NSURL,
204 ) -> Option<Retained<NSURL>>;
205
206 #[cfg(all(feature = "NSArray", feature = "NSString", feature = "NSURL"))]
207 #[unsafe(method(URLsForResourcesWithExtension:subdirectory:inBundleWithURL:))]
208 #[unsafe(method_family = none)]
209 pub fn URLsForResourcesWithExtension_subdirectory_inBundleWithURL(
210 ext: Option<&NSString>,
211 subpath: Option<&NSString>,
212 bundle_url: &NSURL,
213 ) -> Option<Retained<NSArray<NSURL>>>;
214
215 #[cfg(all(feature = "NSString", feature = "NSURL"))]
216 #[unsafe(method(URLForResource:withExtension:))]
217 #[unsafe(method_family = none)]
218 pub fn URLForResource_withExtension(
219 &self,
220 name: Option<&NSString>,
221 ext: Option<&NSString>,
222 ) -> Option<Retained<NSURL>>;
223
224 #[cfg(all(feature = "NSString", feature = "NSURL"))]
225 #[unsafe(method(URLForResource:withExtension:subdirectory:))]
226 #[unsafe(method_family = none)]
227 pub fn URLForResource_withExtension_subdirectory(
228 &self,
229 name: Option<&NSString>,
230 ext: Option<&NSString>,
231 subpath: Option<&NSString>,
232 ) -> Option<Retained<NSURL>>;
233
234 #[cfg(all(feature = "NSString", feature = "NSURL"))]
235 #[unsafe(method(URLForResource:withExtension:subdirectory:localization:))]
236 #[unsafe(method_family = none)]
237 pub fn URLForResource_withExtension_subdirectory_localization(
238 &self,
239 name: Option<&NSString>,
240 ext: Option<&NSString>,
241 subpath: Option<&NSString>,
242 localization_name: Option<&NSString>,
243 ) -> Option<Retained<NSURL>>;
244
245 #[cfg(all(feature = "NSArray", feature = "NSString", feature = "NSURL"))]
246 #[unsafe(method(URLsForResourcesWithExtension:subdirectory:))]
247 #[unsafe(method_family = none)]
248 pub fn URLsForResourcesWithExtension_subdirectory(
249 &self,
250 ext: Option<&NSString>,
251 subpath: Option<&NSString>,
252 ) -> Option<Retained<NSArray<NSURL>>>;
253
254 #[cfg(all(feature = "NSArray", feature = "NSString", feature = "NSURL"))]
255 #[unsafe(method(URLsForResourcesWithExtension:subdirectory:localization:))]
256 #[unsafe(method_family = none)]
257 pub fn URLsForResourcesWithExtension_subdirectory_localization(
258 &self,
259 ext: Option<&NSString>,
260 subpath: Option<&NSString>,
261 localization_name: Option<&NSString>,
262 ) -> Option<Retained<NSArray<NSURL>>>;
263
264 #[cfg(feature = "NSString")]
265 #[unsafe(method(pathForResource:ofType:inDirectory:))]
266 #[unsafe(method_family = none)]
267 pub fn pathForResource_ofType_inDirectory_class(
268 name: Option<&NSString>,
269 ext: Option<&NSString>,
270 bundle_path: &NSString,
271 ) -> Option<Retained<NSString>>;
272
273 #[cfg(all(feature = "NSArray", feature = "NSString"))]
274 #[unsafe(method(pathsForResourcesOfType:inDirectory:))]
275 #[unsafe(method_family = none)]
276 pub fn pathsForResourcesOfType_inDirectory_class(
277 ext: Option<&NSString>,
278 bundle_path: &NSString,
279 ) -> Retained<NSArray<NSString>>;
280
281 #[cfg(feature = "NSString")]
282 #[unsafe(method(pathForResource:ofType:))]
283 #[unsafe(method_family = none)]
284 pub fn pathForResource_ofType(
285 &self,
286 name: Option<&NSString>,
287 ext: Option<&NSString>,
288 ) -> Option<Retained<NSString>>;
289
290 #[cfg(feature = "NSString")]
291 #[unsafe(method(pathForResource:ofType:inDirectory:))]
292 #[unsafe(method_family = none)]
293 pub fn pathForResource_ofType_inDirectory(
294 &self,
295 name: Option<&NSString>,
296 ext: Option<&NSString>,
297 subpath: Option<&NSString>,
298 ) -> Option<Retained<NSString>>;
299
300 #[cfg(feature = "NSString")]
301 #[unsafe(method(pathForResource:ofType:inDirectory:forLocalization:))]
302 #[unsafe(method_family = none)]
303 pub fn pathForResource_ofType_inDirectory_forLocalization(
304 &self,
305 name: Option<&NSString>,
306 ext: Option<&NSString>,
307 subpath: Option<&NSString>,
308 localization_name: Option<&NSString>,
309 ) -> Option<Retained<NSString>>;
310
311 #[cfg(all(feature = "NSArray", feature = "NSString"))]
312 #[unsafe(method(pathsForResourcesOfType:inDirectory:))]
313 #[unsafe(method_family = none)]
314 pub fn pathsForResourcesOfType_inDirectory(
315 &self,
316 ext: Option<&NSString>,
317 subpath: Option<&NSString>,
318 ) -> Retained<NSArray<NSString>>;
319
320 #[cfg(all(feature = "NSArray", feature = "NSString"))]
321 #[unsafe(method(pathsForResourcesOfType:inDirectory:forLocalization:))]
322 #[unsafe(method_family = none)]
323 pub fn pathsForResourcesOfType_inDirectory_forLocalization(
324 &self,
325 ext: Option<&NSString>,
326 subpath: Option<&NSString>,
327 localization_name: Option<&NSString>,
328 ) -> Retained<NSArray<NSString>>;
329
330 #[cfg(feature = "NSString")]
331 #[unsafe(method(localizedStringForKey:value:table:))]
332 #[unsafe(method_family = none)]
333 pub fn localizedStringForKey_value_table(
334 &self,
335 key: &NSString,
336 value: Option<&NSString>,
337 table_name: Option<&NSString>,
338 ) -> Retained<NSString>;
339
340 #[cfg(all(feature = "NSArray", feature = "NSString"))]
341 #[unsafe(method(localizedStringForKey:value:table:localizations:))]
349 #[unsafe(method_family = none)]
350 pub fn localizedStringForKey_value_table_localizations(
351 &self,
352 key: &NSString,
353 value: Option<&NSString>,
354 table_name: Option<&NSString>,
355 localizations: &NSArray<NSString>,
356 ) -> Retained<NSString>;
357
358 #[cfg(feature = "NSString")]
359 #[unsafe(method(bundleIdentifier))]
360 #[unsafe(method_family = none)]
361 pub fn bundleIdentifier(&self) -> Option<Retained<NSString>>;
362
363 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
364 #[unsafe(method(infoDictionary))]
365 #[unsafe(method_family = none)]
366 pub fn infoDictionary(&self) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
367
368 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
369 #[unsafe(method(localizedInfoDictionary))]
370 #[unsafe(method_family = none)]
371 pub fn localizedInfoDictionary(
372 &self,
373 ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
374
375 #[cfg(feature = "NSString")]
376 #[unsafe(method(objectForInfoDictionaryKey:))]
377 #[unsafe(method_family = none)]
378 pub fn objectForInfoDictionaryKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;
379
380 #[cfg(feature = "NSString")]
381 #[unsafe(method(classNamed:))]
382 #[unsafe(method_family = none)]
383 pub fn classNamed(&self, class_name: &NSString) -> Option<&'static AnyClass>;
384
385 #[unsafe(method(principalClass))]
386 #[unsafe(method_family = none)]
387 pub fn principalClass(&self) -> Option<&'static AnyClass>;
388
389 #[cfg(all(feature = "NSArray", feature = "NSString"))]
390 #[unsafe(method(preferredLocalizations))]
391 #[unsafe(method_family = none)]
392 pub fn preferredLocalizations(&self) -> Retained<NSArray<NSString>>;
393
394 #[cfg(all(feature = "NSArray", feature = "NSString"))]
395 #[unsafe(method(localizations))]
396 #[unsafe(method_family = none)]
397 pub fn localizations(&self) -> Retained<NSArray<NSString>>;
398
399 #[cfg(feature = "NSString")]
400 #[unsafe(method(developmentLocalization))]
401 #[unsafe(method_family = none)]
402 pub fn developmentLocalization(&self) -> Option<Retained<NSString>>;
403
404 #[cfg(all(feature = "NSArray", feature = "NSString"))]
405 #[unsafe(method(preferredLocalizationsFromArray:))]
406 #[unsafe(method_family = none)]
407 pub fn preferredLocalizationsFromArray(
408 localizations_array: &NSArray<NSString>,
409 ) -> Retained<NSArray<NSString>>;
410
411 #[cfg(all(feature = "NSArray", feature = "NSString"))]
412 #[unsafe(method(preferredLocalizationsFromArray:forPreferences:))]
413 #[unsafe(method_family = none)]
414 pub fn preferredLocalizationsFromArray_forPreferences(
415 localizations_array: &NSArray<NSString>,
416 preferences_array: Option<&NSArray<NSString>>,
417 ) -> Retained<NSArray<NSString>>;
418
419 #[cfg(all(feature = "NSArray", feature = "NSValue"))]
420 #[unsafe(method(executableArchitectures))]
421 #[unsafe(method_family = none)]
422 pub fn executableArchitectures(&self) -> Option<Retained<NSArray<NSNumber>>>;
423 );
424}
425
426impl NSBundle {
428 extern_methods!(
429 #[unsafe(method(init))]
430 #[unsafe(method_family = init)]
431 pub fn init(this: Allocated<Self>) -> Retained<Self>;
432
433 #[unsafe(method(new))]
434 #[unsafe(method_family = new)]
435 pub fn new() -> Retained<Self>;
436 );
437}
438
439impl DefaultRetained for NSBundle {
440 #[inline]
441 fn default_retained() -> Retained<Self> {
442 Self::new()
443 }
444}
445
446#[cfg(feature = "NSString")]
448impl NSString {
449 extern_methods!(
450 #[unsafe(method(variantFittingPresentationWidth:))]
451 #[unsafe(method_family = none)]
452 pub fn variantFittingPresentationWidth(&self, width: NSInteger) -> Retained<NSString>;
453 );
454}
455
456extern "C" {
457 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
459 pub static NSBundleDidLoadNotification: &'static NSNotificationName;
460}
461
462extern "C" {
463 #[cfg(feature = "NSString")]
465 pub static NSLoadedClasses: &'static NSString;
466}
467
468extern_class!(
469 #[unsafe(super(NSObject))]
471 #[derive(Debug, PartialEq, Eq, Hash)]
472 pub struct NSBundleResourceRequest;
473);
474
475extern_conformance!(
476 unsafe impl NSObjectProtocol for NSBundleResourceRequest {}
477);
478
479#[cfg(feature = "NSProgress")]
480extern_conformance!(
481 unsafe impl NSProgressReporting for NSBundleResourceRequest {}
482);
483
484impl NSBundleResourceRequest {
485 extern_methods!(
486 #[unsafe(method(init))]
487 #[unsafe(method_family = init)]
488 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
489
490 #[cfg(all(feature = "NSSet", feature = "NSString"))]
491 #[unsafe(method(initWithTags:))]
492 #[unsafe(method_family = init)]
493 pub fn initWithTags(this: Allocated<Self>, tags: &NSSet<NSString>) -> Retained<Self>;
494
495 #[cfg(all(feature = "NSSet", feature = "NSString"))]
496 #[unsafe(method(initWithTags:bundle:))]
497 #[unsafe(method_family = init)]
498 pub fn initWithTags_bundle(
499 this: Allocated<Self>,
500 tags: &NSSet<NSString>,
501 bundle: &NSBundle,
502 ) -> Retained<Self>;
503
504 #[unsafe(method(loadingPriority))]
505 #[unsafe(method_family = none)]
506 pub fn loadingPriority(&self) -> c_double;
507
508 #[unsafe(method(setLoadingPriority:))]
510 #[unsafe(method_family = none)]
511 pub fn setLoadingPriority(&self, loading_priority: c_double);
512
513 #[cfg(all(feature = "NSSet", feature = "NSString"))]
514 #[unsafe(method(tags))]
515 #[unsafe(method_family = none)]
516 pub fn tags(&self) -> Retained<NSSet<NSString>>;
517
518 #[unsafe(method(bundle))]
519 #[unsafe(method_family = none)]
520 pub fn bundle(&self) -> Retained<NSBundle>;
521
522 #[cfg(all(feature = "NSError", feature = "block2"))]
523 #[unsafe(method(beginAccessingResourcesWithCompletionHandler:))]
527 #[unsafe(method_family = none)]
528 pub unsafe fn beginAccessingResourcesWithCompletionHandler(
529 &self,
530 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
531 );
532
533 #[cfg(feature = "block2")]
534 #[unsafe(method(conditionallyBeginAccessingResourcesWithCompletionHandler:))]
538 #[unsafe(method_family = none)]
539 pub unsafe fn conditionallyBeginAccessingResourcesWithCompletionHandler(
540 &self,
541 completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
542 );
543
544 #[unsafe(method(endAccessingResources))]
545 #[unsafe(method_family = none)]
546 pub fn endAccessingResources(&self);
547
548 #[cfg(feature = "NSProgress")]
549 #[unsafe(method(progress))]
550 #[unsafe(method_family = none)]
551 pub fn progress(&self) -> Retained<NSProgress>;
552 );
553}
554
555impl NSBundleResourceRequest {
557 extern_methods!(
558 #[unsafe(method(new))]
559 #[unsafe(method_family = new)]
560 pub unsafe fn new() -> Retained<Self>;
561 );
562}
563
564impl NSBundle {
566 extern_methods!(
567 #[cfg(all(feature = "NSSet", feature = "NSString"))]
568 #[unsafe(method(setPreservationPriority:forTags:))]
569 #[unsafe(method_family = none)]
570 pub fn setPreservationPriority_forTags(&self, priority: c_double, tags: &NSSet<NSString>);
571
572 #[cfg(feature = "NSString")]
573 #[unsafe(method(preservationPriorityForTag:))]
574 #[unsafe(method_family = none)]
575 pub fn preservationPriorityForTag(&self, tag: &NSString) -> c_double;
576 );
577}
578
579extern "C" {
580 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
582 pub static NSBundleResourceRequestLowDiskSpaceNotification: &'static NSNotificationName;
583}
584
585extern "C" {
586 pub static NSBundleResourceRequestLoadingPriorityUrgent: c_double;
588}