objc2-foundation 0.3.2

Bindings to the Foundation framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbundleexecutablearchitecturei386?language=objc)
pub const NSBundleExecutableArchitectureI386: c_uint = 0x00000007;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbundleexecutablearchitectureppc?language=objc)
pub const NSBundleExecutableArchitecturePPC: c_uint = 0x00000012;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbundleexecutablearchitecturex86_64?language=objc)
pub const NSBundleExecutableArchitectureX86_64: c_uint = 0x01000007;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbundleexecutablearchitectureppc64?language=objc)
pub const NSBundleExecutableArchitecturePPC64: c_uint = 0x01000012;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbundleexecutablearchitecturearm64?language=objc)
pub const NSBundleExecutableArchitectureARM64: c_uint = 0x0100000c;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbundle?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSBundle;
);

unsafe impl Send for NSBundle {}

unsafe impl Sync for NSBundle {}

extern_conformance!(
    unsafe impl NSObjectProtocol for NSBundle {}
);

impl NSBundle {
    extern_methods!(
        #[unsafe(method(mainBundle))]
        #[unsafe(method_family = none)]
        pub fn mainBundle() -> Retained<NSBundle>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(bundleWithPath:))]
        #[unsafe(method_family = none)]
        pub fn bundleWithPath(path: &NSString) -> Option<Retained<Self>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(initWithPath:))]
        #[unsafe(method_family = init)]
        pub fn initWithPath(this: Allocated<Self>, path: &NSString) -> Option<Retained<Self>>;

        #[cfg(feature = "NSURL")]
        #[unsafe(method(bundleWithURL:))]
        #[unsafe(method_family = none)]
        pub fn bundleWithURL(url: &NSURL) -> Option<Retained<Self>>;

        #[cfg(feature = "NSURL")]
        #[unsafe(method(initWithURL:))]
        #[unsafe(method_family = init)]
        pub fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;

        /// # Safety
        ///
        /// `a_class` probably has further requirements.
        #[unsafe(method(bundleForClass:))]
        #[unsafe(method_family = none)]
        pub unsafe fn bundleForClass(a_class: &AnyClass) -> Retained<NSBundle>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(bundleWithIdentifier:))]
        #[unsafe(method_family = none)]
        pub fn bundleWithIdentifier(identifier: &NSString) -> Option<Retained<NSBundle>>;

        #[cfg(feature = "NSArray")]
        #[unsafe(method(allBundles))]
        #[unsafe(method_family = none)]
        pub unsafe fn allBundles() -> Retained<NSArray<NSBundle>>;

        #[cfg(feature = "NSArray")]
        #[unsafe(method(allFrameworks))]
        #[unsafe(method_family = none)]
        pub unsafe fn allFrameworks() -> Retained<NSArray<NSBundle>>;

        #[unsafe(method(load))]
        #[unsafe(method_family = none)]
        pub unsafe fn load(&self) -> bool;

        #[unsafe(method(isLoaded))]
        #[unsafe(method_family = none)]
        pub fn isLoaded(&self) -> bool;

        #[unsafe(method(unload))]
        #[unsafe(method_family = none)]
        pub unsafe fn unload(&self) -> bool;

        #[cfg(feature = "NSError")]
        #[unsafe(method(preflightAndReturnError:_))]
        #[unsafe(method_family = none)]
        pub fn preflightAndReturnError(&self) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "NSError")]
        #[unsafe(method(loadAndReturnError:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadAndReturnError(&self) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "NSURL")]
        #[unsafe(method(bundleURL))]
        #[unsafe(method_family = none)]
        pub fn bundleURL(&self) -> Retained<NSURL>;

        #[cfg(feature = "NSURL")]
        #[unsafe(method(resourceURL))]
        #[unsafe(method_family = none)]
        pub fn resourceURL(&self) -> Option<Retained<NSURL>>;

        #[cfg(feature = "NSURL")]
        #[unsafe(method(executableURL))]
        #[unsafe(method_family = none)]
        pub fn executableURL(&self) -> Option<Retained<NSURL>>;

        #[cfg(all(feature = "NSString", feature = "NSURL"))]
        #[unsafe(method(URLForAuxiliaryExecutable:))]
        #[unsafe(method_family = none)]
        pub fn URLForAuxiliaryExecutable(
            &self,
            executable_name: &NSString,
        ) -> Option<Retained<NSURL>>;

        #[cfg(feature = "NSURL")]
        #[unsafe(method(privateFrameworksURL))]
        #[unsafe(method_family = none)]
        pub fn privateFrameworksURL(&self) -> Option<Retained<NSURL>>;

        #[cfg(feature = "NSURL")]
        #[unsafe(method(sharedFrameworksURL))]
        #[unsafe(method_family = none)]
        pub fn sharedFrameworksURL(&self) -> Option<Retained<NSURL>>;

        #[cfg(feature = "NSURL")]
        #[unsafe(method(sharedSupportURL))]
        #[unsafe(method_family = none)]
        pub fn sharedSupportURL(&self) -> Option<Retained<NSURL>>;

        #[cfg(feature = "NSURL")]
        #[unsafe(method(builtInPlugInsURL))]
        #[unsafe(method_family = none)]
        pub fn builtInPlugInsURL(&self) -> Option<Retained<NSURL>>;

        #[cfg(feature = "NSURL")]
        #[unsafe(method(appStoreReceiptURL))]
        #[unsafe(method_family = none)]
        pub fn appStoreReceiptURL(&self) -> Option<Retained<NSURL>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(bundlePath))]
        #[unsafe(method_family = none)]
        pub fn bundlePath(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(resourcePath))]
        #[unsafe(method_family = none)]
        pub fn resourcePath(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(executablePath))]
        #[unsafe(method_family = none)]
        pub fn executablePath(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(pathForAuxiliaryExecutable:))]
        #[unsafe(method_family = none)]
        pub fn pathForAuxiliaryExecutable(
            &self,
            executable_name: &NSString,
        ) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(privateFrameworksPath))]
        #[unsafe(method_family = none)]
        pub fn privateFrameworksPath(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(sharedFrameworksPath))]
        #[unsafe(method_family = none)]
        pub fn sharedFrameworksPath(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(sharedSupportPath))]
        #[unsafe(method_family = none)]
        pub fn sharedSupportPath(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(builtInPlugInsPath))]
        #[unsafe(method_family = none)]
        pub fn builtInPlugInsPath(&self) -> Option<Retained<NSString>>;

        #[cfg(all(feature = "NSString", feature = "NSURL"))]
        #[unsafe(method(URLForResource:withExtension:subdirectory:inBundleWithURL:))]
        #[unsafe(method_family = none)]
        pub fn URLForResource_withExtension_subdirectory_inBundleWithURL(
            name: Option<&NSString>,
            ext: Option<&NSString>,
            subpath: Option<&NSString>,
            bundle_url: &NSURL,
        ) -> Option<Retained<NSURL>>;

        #[cfg(all(feature = "NSArray", feature = "NSString", feature = "NSURL"))]
        #[unsafe(method(URLsForResourcesWithExtension:subdirectory:inBundleWithURL:))]
        #[unsafe(method_family = none)]
        pub fn URLsForResourcesWithExtension_subdirectory_inBundleWithURL(
            ext: Option<&NSString>,
            subpath: Option<&NSString>,
            bundle_url: &NSURL,
        ) -> Option<Retained<NSArray<NSURL>>>;

        #[cfg(all(feature = "NSString", feature = "NSURL"))]
        #[unsafe(method(URLForResource:withExtension:))]
        #[unsafe(method_family = none)]
        pub fn URLForResource_withExtension(
            &self,
            name: Option<&NSString>,
            ext: Option<&NSString>,
        ) -> Option<Retained<NSURL>>;

        #[cfg(all(feature = "NSString", feature = "NSURL"))]
        #[unsafe(method(URLForResource:withExtension:subdirectory:))]
        #[unsafe(method_family = none)]
        pub fn URLForResource_withExtension_subdirectory(
            &self,
            name: Option<&NSString>,
            ext: Option<&NSString>,
            subpath: Option<&NSString>,
        ) -> Option<Retained<NSURL>>;

        #[cfg(all(feature = "NSString", feature = "NSURL"))]
        #[unsafe(method(URLForResource:withExtension:subdirectory:localization:))]
        #[unsafe(method_family = none)]
        pub fn URLForResource_withExtension_subdirectory_localization(
            &self,
            name: Option<&NSString>,
            ext: Option<&NSString>,
            subpath: Option<&NSString>,
            localization_name: Option<&NSString>,
        ) -> Option<Retained<NSURL>>;

        #[cfg(all(feature = "NSArray", feature = "NSString", feature = "NSURL"))]
        #[unsafe(method(URLsForResourcesWithExtension:subdirectory:))]
        #[unsafe(method_family = none)]
        pub fn URLsForResourcesWithExtension_subdirectory(
            &self,
            ext: Option<&NSString>,
            subpath: Option<&NSString>,
        ) -> Option<Retained<NSArray<NSURL>>>;

        #[cfg(all(feature = "NSArray", feature = "NSString", feature = "NSURL"))]
        #[unsafe(method(URLsForResourcesWithExtension:subdirectory:localization:))]
        #[unsafe(method_family = none)]
        pub fn URLsForResourcesWithExtension_subdirectory_localization(
            &self,
            ext: Option<&NSString>,
            subpath: Option<&NSString>,
            localization_name: Option<&NSString>,
        ) -> Option<Retained<NSArray<NSURL>>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(pathForResource:ofType:inDirectory:))]
        #[unsafe(method_family = none)]
        pub fn pathForResource_ofType_inDirectory_class(
            name: Option<&NSString>,
            ext: Option<&NSString>,
            bundle_path: &NSString,
        ) -> Option<Retained<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(pathsForResourcesOfType:inDirectory:))]
        #[unsafe(method_family = none)]
        pub fn pathsForResourcesOfType_inDirectory_class(
            ext: Option<&NSString>,
            bundle_path: &NSString,
        ) -> Retained<NSArray<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(pathForResource:ofType:))]
        #[unsafe(method_family = none)]
        pub fn pathForResource_ofType(
            &self,
            name: Option<&NSString>,
            ext: Option<&NSString>,
        ) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(pathForResource:ofType:inDirectory:))]
        #[unsafe(method_family = none)]
        pub fn pathForResource_ofType_inDirectory(
            &self,
            name: Option<&NSString>,
            ext: Option<&NSString>,
            subpath: Option<&NSString>,
        ) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(pathForResource:ofType:inDirectory:forLocalization:))]
        #[unsafe(method_family = none)]
        pub fn pathForResource_ofType_inDirectory_forLocalization(
            &self,
            name: Option<&NSString>,
            ext: Option<&NSString>,
            subpath: Option<&NSString>,
            localization_name: Option<&NSString>,
        ) -> Option<Retained<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(pathsForResourcesOfType:inDirectory:))]
        #[unsafe(method_family = none)]
        pub fn pathsForResourcesOfType_inDirectory(
            &self,
            ext: Option<&NSString>,
            subpath: Option<&NSString>,
        ) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(pathsForResourcesOfType:inDirectory:forLocalization:))]
        #[unsafe(method_family = none)]
        pub fn pathsForResourcesOfType_inDirectory_forLocalization(
            &self,
            ext: Option<&NSString>,
            subpath: Option<&NSString>,
            localization_name: Option<&NSString>,
        ) -> Retained<NSArray<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(localizedStringForKey:value:table:))]
        #[unsafe(method_family = none)]
        pub fn localizedStringForKey_value_table(
            &self,
            key: &NSString,
            value: Option<&NSString>,
            table_name: Option<&NSString>,
        ) -> Retained<NSString>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        /// Look up a localized string given a list of available localizations.
        /// - Parameters:
        /// - key: The key for the localized string to retrieve.
        /// - value: A default value to return if a localized string for ``key`` cannot be found.
        /// - tableName: The name of the strings file to search. If `nil`, the method uses tables in `Localizable.strings`.
        /// - localizations: An array of BCP 47 language codes corresponding to available localizations. Bundle compares the array against its available localizations, and uses the best result to retrieve the localized string. If empty, we treat it as no localization is available, and may return a fallback.
        /// - Returns: A localized version of the string designated by ``key`` in table ``tableName``.
        #[unsafe(method(localizedStringForKey:value:table:localizations:))]
        #[unsafe(method_family = none)]
        pub fn localizedStringForKey_value_table_localizations(
            &self,
            key: &NSString,
            value: Option<&NSString>,
            table_name: Option<&NSString>,
            localizations: &NSArray<NSString>,
        ) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(bundleIdentifier))]
        #[unsafe(method_family = none)]
        pub fn bundleIdentifier(&self) -> Option<Retained<NSString>>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(infoDictionary))]
        #[unsafe(method_family = none)]
        pub fn infoDictionary(&self) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(localizedInfoDictionary))]
        #[unsafe(method_family = none)]
        pub fn localizedInfoDictionary(
            &self,
        ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(objectForInfoDictionaryKey:))]
        #[unsafe(method_family = none)]
        pub fn objectForInfoDictionaryKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(classNamed:))]
        #[unsafe(method_family = none)]
        pub fn classNamed(&self, class_name: &NSString) -> Option<&'static AnyClass>;

        #[unsafe(method(principalClass))]
        #[unsafe(method_family = none)]
        pub fn principalClass(&self) -> Option<&'static AnyClass>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(preferredLocalizations))]
        #[unsafe(method_family = none)]
        pub fn preferredLocalizations(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(localizations))]
        #[unsafe(method_family = none)]
        pub fn localizations(&self) -> Retained<NSArray<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(developmentLocalization))]
        #[unsafe(method_family = none)]
        pub fn developmentLocalization(&self) -> Option<Retained<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(preferredLocalizationsFromArray:))]
        #[unsafe(method_family = none)]
        pub fn preferredLocalizationsFromArray(
            localizations_array: &NSArray<NSString>,
        ) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(preferredLocalizationsFromArray:forPreferences:))]
        #[unsafe(method_family = none)]
        pub fn preferredLocalizationsFromArray_forPreferences(
            localizations_array: &NSArray<NSString>,
            preferences_array: Option<&NSArray<NSString>>,
        ) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSValue"))]
        #[unsafe(method(executableArchitectures))]
        #[unsafe(method_family = none)]
        pub fn executableArchitectures(&self) -> Option<Retained<NSArray<NSNumber>>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSBundle {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for NSBundle {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

/// NSBundleExtensionMethods.
#[cfg(feature = "NSString")]
impl NSString {
    extern_methods!(
        #[unsafe(method(variantFittingPresentationWidth:))]
        #[unsafe(method_family = none)]
        pub fn variantFittingPresentationWidth(&self, width: NSInteger) -> Retained<NSString>;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbundledidloadnotification?language=objc)
    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
    pub static NSBundleDidLoadNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsloadedclasses?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSLoadedClasses: &'static NSString;
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbundleresourcerequest?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSBundleResourceRequest;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NSBundleResourceRequest {}
);

#[cfg(feature = "NSProgress")]
extern_conformance!(
    unsafe impl NSProgressReporting for NSBundleResourceRequest {}
);

impl NSBundleResourceRequest {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(all(feature = "NSSet", feature = "NSString"))]
        #[unsafe(method(initWithTags:))]
        #[unsafe(method_family = init)]
        pub fn initWithTags(this: Allocated<Self>, tags: &NSSet<NSString>) -> Retained<Self>;

        #[cfg(all(feature = "NSSet", feature = "NSString"))]
        #[unsafe(method(initWithTags:bundle:))]
        #[unsafe(method_family = init)]
        pub fn initWithTags_bundle(
            this: Allocated<Self>,
            tags: &NSSet<NSString>,
            bundle: &NSBundle,
        ) -> Retained<Self>;

        #[unsafe(method(loadingPriority))]
        #[unsafe(method_family = none)]
        pub fn loadingPriority(&self) -> c_double;

        /// Setter for [`loadingPriority`][Self::loadingPriority].
        #[unsafe(method(setLoadingPriority:))]
        #[unsafe(method_family = none)]
        pub fn setLoadingPriority(&self, loading_priority: c_double);

        #[cfg(all(feature = "NSSet", feature = "NSString"))]
        #[unsafe(method(tags))]
        #[unsafe(method_family = none)]
        pub fn tags(&self) -> Retained<NSSet<NSString>>;

        #[unsafe(method(bundle))]
        #[unsafe(method_family = none)]
        pub fn bundle(&self) -> Retained<NSBundle>;

        #[cfg(all(feature = "NSError", feature = "block2"))]
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(beginAccessingResourcesWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn beginAccessingResourcesWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(conditionallyBeginAccessingResourcesWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn conditionallyBeginAccessingResourcesWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
        );

        #[unsafe(method(endAccessingResources))]
        #[unsafe(method_family = none)]
        pub fn endAccessingResources(&self);

        #[cfg(feature = "NSProgress")]
        #[unsafe(method(progress))]
        #[unsafe(method_family = none)]
        pub fn progress(&self) -> Retained<NSProgress>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSBundleResourceRequest {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// NSBundleResourceRequestAdditions.
impl NSBundle {
    extern_methods!(
        #[cfg(all(feature = "NSSet", feature = "NSString"))]
        #[unsafe(method(setPreservationPriority:forTags:))]
        #[unsafe(method_family = none)]
        pub fn setPreservationPriority_forTags(&self, priority: c_double, tags: &NSSet<NSString>);

        #[cfg(feature = "NSString")]
        #[unsafe(method(preservationPriorityForTag:))]
        #[unsafe(method_family = none)]
        pub fn preservationPriorityForTag(&self, tag: &NSString) -> c_double;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbundleresourcerequestlowdiskspacenotification?language=objc)
    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
    pub static NSBundleResourceRequestLowDiskSpaceNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbundleresourcerequestloadingpriorityurgent?language=objc)
    pub static NSBundleResourceRequestLoadingPriorityUrgent: c_double;
}