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 unsafe fn bundleWithPath(path: &NSString) -> Option<Retained<Self>>;
45
46 #[cfg(feature = "NSString")]
47 #[unsafe(method(initWithPath:))]
48 #[unsafe(method_family = init)]
49 pub unsafe fn initWithPath(
50 this: Allocated<Self>,
51 path: &NSString,
52 ) -> Option<Retained<Self>>;
53
54 #[cfg(feature = "NSURL")]
55 #[unsafe(method(bundleWithURL:))]
56 #[unsafe(method_family = none)]
57 pub unsafe fn bundleWithURL(url: &NSURL) -> Option<Retained<Self>>;
58
59 #[cfg(feature = "NSURL")]
60 #[unsafe(method(initWithURL:))]
61 #[unsafe(method_family = init)]
62 pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;
63
64 #[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 unsafe 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 unsafe 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 unsafe 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 unsafe fn bundleURL(&self) -> Retained<NSURL>;
109
110 #[cfg(feature = "NSURL")]
111 #[unsafe(method(resourceURL))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn resourceURL(&self) -> Option<Retained<NSURL>>;
114
115 #[cfg(feature = "NSURL")]
116 #[unsafe(method(executableURL))]
117 #[unsafe(method_family = none)]
118 pub unsafe 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 unsafe 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 unsafe fn privateFrameworksURL(&self) -> Option<Retained<NSURL>>;
132
133 #[cfg(feature = "NSURL")]
134 #[unsafe(method(sharedFrameworksURL))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn sharedFrameworksURL(&self) -> Option<Retained<NSURL>>;
137
138 #[cfg(feature = "NSURL")]
139 #[unsafe(method(sharedSupportURL))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn sharedSupportURL(&self) -> Option<Retained<NSURL>>;
142
143 #[cfg(feature = "NSURL")]
144 #[unsafe(method(builtInPlugInsURL))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn builtInPlugInsURL(&self) -> Option<Retained<NSURL>>;
147
148 #[cfg(feature = "NSURL")]
149 #[unsafe(method(appStoreReceiptURL))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn appStoreReceiptURL(&self) -> Option<Retained<NSURL>>;
152
153 #[cfg(feature = "NSString")]
154 #[unsafe(method(bundlePath))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn bundlePath(&self) -> Retained<NSString>;
157
158 #[cfg(feature = "NSString")]
159 #[unsafe(method(resourcePath))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn resourcePath(&self) -> Option<Retained<NSString>>;
162
163 #[cfg(feature = "NSString")]
164 #[unsafe(method(executablePath))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn executablePath(&self) -> Option<Retained<NSString>>;
167
168 #[cfg(feature = "NSString")]
169 #[unsafe(method(pathForAuxiliaryExecutable:))]
170 #[unsafe(method_family = none)]
171 pub unsafe 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 unsafe fn privateFrameworksPath(&self) -> Option<Retained<NSString>>;
180
181 #[cfg(feature = "NSString")]
182 #[unsafe(method(sharedFrameworksPath))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn sharedFrameworksPath(&self) -> Option<Retained<NSString>>;
185
186 #[cfg(feature = "NSString")]
187 #[unsafe(method(sharedSupportPath))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn sharedSupportPath(&self) -> Option<Retained<NSString>>;
190
191 #[cfg(feature = "NSString")]
192 #[unsafe(method(builtInPlugInsPath))]
193 #[unsafe(method_family = none)]
194 pub unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe fn objectForInfoDictionaryKey(
379 &self,
380 key: &NSString,
381 ) -> Option<Retained<AnyObject>>;
382
383 #[cfg(feature = "NSString")]
384 #[unsafe(method(classNamed:))]
385 #[unsafe(method_family = none)]
386 pub unsafe fn classNamed(&self, class_name: &NSString) -> Option<&'static AnyClass>;
387
388 #[unsafe(method(principalClass))]
389 #[unsafe(method_family = none)]
390 pub unsafe fn principalClass(&self) -> Option<&'static AnyClass>;
391
392 #[cfg(all(feature = "NSArray", feature = "NSString"))]
393 #[unsafe(method(preferredLocalizations))]
394 #[unsafe(method_family = none)]
395 pub unsafe fn preferredLocalizations(&self) -> Retained<NSArray<NSString>>;
396
397 #[cfg(all(feature = "NSArray", feature = "NSString"))]
398 #[unsafe(method(localizations))]
399 #[unsafe(method_family = none)]
400 pub unsafe fn localizations(&self) -> Retained<NSArray<NSString>>;
401
402 #[cfg(feature = "NSString")]
403 #[unsafe(method(developmentLocalization))]
404 #[unsafe(method_family = none)]
405 pub unsafe fn developmentLocalization(&self) -> Option<Retained<NSString>>;
406
407 #[cfg(all(feature = "NSArray", feature = "NSString"))]
408 #[unsafe(method(preferredLocalizationsFromArray:))]
409 #[unsafe(method_family = none)]
410 pub unsafe fn preferredLocalizationsFromArray(
411 localizations_array: &NSArray<NSString>,
412 ) -> Retained<NSArray<NSString>>;
413
414 #[cfg(all(feature = "NSArray", feature = "NSString"))]
415 #[unsafe(method(preferredLocalizationsFromArray:forPreferences:))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn preferredLocalizationsFromArray_forPreferences(
418 localizations_array: &NSArray<NSString>,
419 preferences_array: Option<&NSArray<NSString>>,
420 ) -> Retained<NSArray<NSString>>;
421
422 #[cfg(all(feature = "NSArray", feature = "NSValue"))]
423 #[unsafe(method(executableArchitectures))]
424 #[unsafe(method_family = none)]
425 pub unsafe fn executableArchitectures(&self) -> Option<Retained<NSArray<NSNumber>>>;
426 );
427}
428
429impl NSBundle {
431 extern_methods!(
432 #[unsafe(method(init))]
433 #[unsafe(method_family = init)]
434 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
435
436 #[unsafe(method(new))]
437 #[unsafe(method_family = new)]
438 pub unsafe fn new() -> Retained<Self>;
439 );
440}
441
442#[cfg(feature = "NSString")]
444impl NSString {
445 extern_methods!(
446 #[unsafe(method(variantFittingPresentationWidth:))]
447 #[unsafe(method_family = none)]
448 pub unsafe fn variantFittingPresentationWidth(
449 &self,
450 width: NSInteger,
451 ) -> Retained<NSString>;
452 );
453}
454
455extern "C" {
456 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
458 pub static NSBundleDidLoadNotification: &'static NSNotificationName;
459}
460
461extern "C" {
462 #[cfg(feature = "NSString")]
464 pub static NSLoadedClasses: &'static NSString;
465}
466
467extern_class!(
468 #[unsafe(super(NSObject))]
470 #[derive(Debug, PartialEq, Eq, Hash)]
471 pub struct NSBundleResourceRequest;
472);
473
474extern_conformance!(
475 unsafe impl NSObjectProtocol for NSBundleResourceRequest {}
476);
477
478#[cfg(feature = "NSProgress")]
479extern_conformance!(
480 unsafe impl NSProgressReporting for NSBundleResourceRequest {}
481);
482
483impl NSBundleResourceRequest {
484 extern_methods!(
485 #[unsafe(method(init))]
486 #[unsafe(method_family = init)]
487 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
488
489 #[cfg(all(feature = "NSSet", feature = "NSString"))]
490 #[unsafe(method(initWithTags:))]
491 #[unsafe(method_family = init)]
492 pub unsafe fn initWithTags(this: Allocated<Self>, tags: &NSSet<NSString>)
493 -> Retained<Self>;
494
495 #[cfg(all(feature = "NSSet", feature = "NSString"))]
496 #[unsafe(method(initWithTags:bundle:))]
497 #[unsafe(method_family = init)]
498 pub unsafe 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 unsafe fn loadingPriority(&self) -> c_double;
507
508 #[unsafe(method(setLoadingPriority:))]
510 #[unsafe(method_family = none)]
511 pub unsafe 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 unsafe fn tags(&self) -> Retained<NSSet<NSString>>;
517
518 #[unsafe(method(bundle))]
519 #[unsafe(method_family = none)]
520 pub unsafe fn bundle(&self) -> Retained<NSBundle>;
521
522 #[cfg(all(feature = "NSError", feature = "block2"))]
523 #[unsafe(method(beginAccessingResourcesWithCompletionHandler:))]
524 #[unsafe(method_family = none)]
525 pub unsafe fn beginAccessingResourcesWithCompletionHandler(
526 &self,
527 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
528 );
529
530 #[cfg(feature = "block2")]
531 #[unsafe(method(conditionallyBeginAccessingResourcesWithCompletionHandler:))]
532 #[unsafe(method_family = none)]
533 pub unsafe fn conditionallyBeginAccessingResourcesWithCompletionHandler(
534 &self,
535 completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
536 );
537
538 #[unsafe(method(endAccessingResources))]
539 #[unsafe(method_family = none)]
540 pub unsafe fn endAccessingResources(&self);
541
542 #[cfg(feature = "NSProgress")]
543 #[unsafe(method(progress))]
544 #[unsafe(method_family = none)]
545 pub unsafe fn progress(&self) -> Retained<NSProgress>;
546 );
547}
548
549impl NSBundleResourceRequest {
551 extern_methods!(
552 #[unsafe(method(new))]
553 #[unsafe(method_family = new)]
554 pub unsafe fn new() -> Retained<Self>;
555 );
556}
557
558impl NSBundle {
560 extern_methods!(
561 #[cfg(all(feature = "NSSet", feature = "NSString"))]
562 #[unsafe(method(setPreservationPriority:forTags:))]
563 #[unsafe(method_family = none)]
564 pub unsafe fn setPreservationPriority_forTags(
565 &self,
566 priority: c_double,
567 tags: &NSSet<NSString>,
568 );
569
570 #[cfg(feature = "NSString")]
571 #[unsafe(method(preservationPriorityForTag:))]
572 #[unsafe(method_family = none)]
573 pub unsafe fn preservationPriorityForTag(&self, tag: &NSString) -> c_double;
574 );
575}
576
577extern "C" {
578 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
580 pub static NSBundleResourceRequestLowDiskSpaceNotification: &'static NSNotificationName;
581}
582
583extern "C" {
584 pub static NSBundleResourceRequestLoadingPriorityUrgent: c_double;
586}