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