objc2_foundation/generated/
NSString.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-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/foundation/unichar?language=objc)
12pub type unichar = c_ushort;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringcompareoptions?language=objc)
15// NS_OPTIONS
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct NSStringCompareOptions(pub NSUInteger);
19bitflags::bitflags! {
20    impl NSStringCompareOptions: NSUInteger {
21        #[doc(alias = "NSCaseInsensitiveSearch")]
22        const CaseInsensitiveSearch = 1;
23        #[doc(alias = "NSLiteralSearch")]
24        const LiteralSearch = 2;
25        #[doc(alias = "NSBackwardsSearch")]
26        const BackwardsSearch = 4;
27        #[doc(alias = "NSAnchoredSearch")]
28        const AnchoredSearch = 8;
29        #[doc(alias = "NSNumericSearch")]
30        const NumericSearch = 64;
31        #[doc(alias = "NSDiacriticInsensitiveSearch")]
32        const DiacriticInsensitiveSearch = 128;
33        #[doc(alias = "NSWidthInsensitiveSearch")]
34        const WidthInsensitiveSearch = 256;
35        #[doc(alias = "NSForcedOrderingSearch")]
36        const ForcedOrderingSearch = 512;
37        #[doc(alias = "NSRegularExpressionSearch")]
38        const RegularExpressionSearch = 1024;
39    }
40}
41
42unsafe impl Encode for NSStringCompareOptions {
43    const ENCODING: Encoding = NSUInteger::ENCODING;
44}
45
46unsafe impl RefEncode for NSStringCompareOptions {
47    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
48}
49
50/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringencoding?language=objc)
51pub type NSStringEncoding = NSUInteger;
52
53/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsasciistringencoding?language=objc)
54pub const NSASCIIStringEncoding: NSStringEncoding = 1;
55/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnextstepstringencoding?language=objc)
56pub const NSNEXTSTEPStringEncoding: NSStringEncoding = 2;
57/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsjapaneseeucstringencoding?language=objc)
58pub const NSJapaneseEUCStringEncoding: NSStringEncoding = 3;
59/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsutf8stringencoding?language=objc)
60pub const NSUTF8StringEncoding: NSStringEncoding = 4;
61/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsisolatin1stringencoding?language=objc)
62pub const NSISOLatin1StringEncoding: NSStringEncoding = 5;
63/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssymbolstringencoding?language=objc)
64pub const NSSymbolStringEncoding: NSStringEncoding = 6;
65/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnonlossyasciistringencoding?language=objc)
66pub const NSNonLossyASCIIStringEncoding: NSStringEncoding = 7;
67/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsshiftjisstringencoding?language=objc)
68pub const NSShiftJISStringEncoding: NSStringEncoding = 8;
69/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsisolatin2stringencoding?language=objc)
70pub const NSISOLatin2StringEncoding: NSStringEncoding = 9;
71/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsunicodestringencoding?language=objc)
72pub const NSUnicodeStringEncoding: NSStringEncoding = 10;
73/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswindowscp1251stringencoding?language=objc)
74pub const NSWindowsCP1251StringEncoding: NSStringEncoding = 11;
75/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswindowscp1252stringencoding?language=objc)
76pub const NSWindowsCP1252StringEncoding: NSStringEncoding = 12;
77/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswindowscp1253stringencoding?language=objc)
78pub const NSWindowsCP1253StringEncoding: NSStringEncoding = 13;
79/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswindowscp1254stringencoding?language=objc)
80pub const NSWindowsCP1254StringEncoding: NSStringEncoding = 14;
81/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswindowscp1250stringencoding?language=objc)
82pub const NSWindowsCP1250StringEncoding: NSStringEncoding = 15;
83/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsiso2022jpstringencoding?language=objc)
84pub const NSISO2022JPStringEncoding: NSStringEncoding = 21;
85/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmacosromanstringencoding?language=objc)
86pub const NSMacOSRomanStringEncoding: NSStringEncoding = 30;
87/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsutf16stringencoding?language=objc)
88pub const NSUTF16StringEncoding: NSStringEncoding = NSUnicodeStringEncoding;
89/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsutf16bigendianstringencoding?language=objc)
90pub const NSUTF16BigEndianStringEncoding: NSStringEncoding = 0x90000100;
91/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsutf16littleendianstringencoding?language=objc)
92pub const NSUTF16LittleEndianStringEncoding: NSStringEncoding = 0x94000100;
93/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsutf32stringencoding?language=objc)
94pub const NSUTF32StringEncoding: NSStringEncoding = 0x8c000100;
95/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsutf32bigendianstringencoding?language=objc)
96pub const NSUTF32BigEndianStringEncoding: NSStringEncoding = 0x98000100;
97/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsutf32littleendianstringencoding?language=objc)
98pub const NSUTF32LittleEndianStringEncoding: NSStringEncoding = 0x9c000100;
99
100/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringencodingconversionoptions?language=objc)
101// NS_OPTIONS
102#[repr(transparent)]
103#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
104pub struct NSStringEncodingConversionOptions(pub NSUInteger);
105bitflags::bitflags! {
106    impl NSStringEncodingConversionOptions: NSUInteger {
107        #[doc(alias = "NSStringEncodingConversionAllowLossy")]
108        const AllowLossy = 1;
109        #[doc(alias = "NSStringEncodingConversionExternalRepresentation")]
110        const ExternalRepresentation = 2;
111    }
112}
113
114unsafe impl Encode for NSStringEncodingConversionOptions {
115    const ENCODING: Encoding = NSUInteger::ENCODING;
116}
117
118unsafe impl RefEncode for NSStringEncodingConversionOptions {
119    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
120}
121
122extern_class!(
123    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstring?language=objc)
124    #[unsafe(super(NSObject))]
125    #[derive(PartialEq, Eq, Hash)]
126    pub struct NSString;
127);
128
129#[cfg(feature = "objc2-core-foundation")]
130impl AsRef<NSString> for CFString {
131    #[inline]
132    fn as_ref(&self) -> &NSString {
133        unsafe { &*((self as *const Self).cast()) }
134    }
135}
136
137#[cfg(feature = "objc2-core-foundation")]
138impl AsRef<CFString> for NSString {
139    #[inline]
140    fn as_ref(&self) -> &CFString {
141        unsafe { &*((self as *const Self).cast()) }
142    }
143}
144
145#[cfg(feature = "NSObject")]
146extern_conformance!(
147    unsafe impl NSCoding for NSString {}
148);
149
150#[cfg(feature = "NSObject")]
151extern_conformance!(
152    unsafe impl NSCopying for NSString {}
153);
154
155#[cfg(feature = "NSObject")]
156unsafe impl CopyingHelper for NSString {
157    type Result = Self;
158}
159
160#[cfg(feature = "NSObject")]
161extern_conformance!(
162    unsafe impl NSMutableCopying for NSString {}
163);
164
165#[cfg(feature = "NSObject")]
166unsafe impl MutableCopyingHelper for NSString {
167    type Result = NSMutableString;
168}
169
170extern_conformance!(
171    unsafe impl NSObjectProtocol for NSString {}
172);
173
174#[cfg(feature = "NSObject")]
175extern_conformance!(
176    unsafe impl NSSecureCoding for NSString {}
177);
178
179impl NSString {
180    extern_methods!(
181        #[unsafe(method(length))]
182        #[unsafe(method_family = none)]
183        pub fn length(&self) -> NSUInteger;
184
185        #[unsafe(method(characterAtIndex:))]
186        #[unsafe(method_family = none)]
187        pub fn characterAtIndex(&self, index: NSUInteger) -> unichar;
188
189        #[unsafe(method(init))]
190        #[unsafe(method_family = init)]
191        pub fn init(this: Allocated<Self>) -> Retained<Self>;
192
193        #[cfg(feature = "NSCoder")]
194        /// # Safety
195        ///
196        /// `coder` possibly has further requirements.
197        #[unsafe(method(initWithCoder:))]
198        #[unsafe(method_family = init)]
199        pub unsafe fn initWithCoder(
200            this: Allocated<Self>,
201            coder: &NSCoder,
202        ) -> Option<Retained<Self>>;
203    );
204}
205
206/// Methods declared on superclass `NSObject`.
207impl NSString {
208    extern_methods!(
209        #[unsafe(method(new))]
210        #[unsafe(method_family = new)]
211        pub fn new() -> Retained<Self>;
212    );
213}
214
215impl DefaultRetained for NSString {
216    #[inline]
217    fn default_retained() -> Retained<Self> {
218        Self::new()
219    }
220}
221
222/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringenumerationoptions?language=objc)
223// NS_OPTIONS
224#[repr(transparent)]
225#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
226pub struct NSStringEnumerationOptions(pub NSUInteger);
227bitflags::bitflags! {
228    impl NSStringEnumerationOptions: NSUInteger {
229        #[doc(alias = "NSStringEnumerationByLines")]
230        const ByLines = 0;
231        #[doc(alias = "NSStringEnumerationByParagraphs")]
232        const ByParagraphs = 1;
233        #[doc(alias = "NSStringEnumerationByComposedCharacterSequences")]
234        const ByComposedCharacterSequences = 2;
235        #[doc(alias = "NSStringEnumerationByWords")]
236        const ByWords = 3;
237        #[doc(alias = "NSStringEnumerationBySentences")]
238        const BySentences = 4;
239        #[doc(alias = "NSStringEnumerationByCaretPositions")]
240        const ByCaretPositions = 5;
241        #[doc(alias = "NSStringEnumerationByDeletionClusters")]
242        const ByDeletionClusters = 6;
243        #[doc(alias = "NSStringEnumerationReverse")]
244        const Reverse = 1<<8;
245        #[doc(alias = "NSStringEnumerationSubstringNotRequired")]
246        const SubstringNotRequired = 1<<9;
247        #[doc(alias = "NSStringEnumerationLocalized")]
248        const Localized = 1<<10;
249    }
250}
251
252unsafe impl Encode for NSStringEnumerationOptions {
253    const ENCODING: Encoding = NSUInteger::ENCODING;
254}
255
256unsafe impl RefEncode for NSStringEnumerationOptions {
257    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
258}
259
260/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransform?language=objc)
261// NS_TYPED_EXTENSIBLE_ENUM
262pub type NSStringTransform = NSString;
263
264extern "C" {
265    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformlatintokatakana?language=objc)
266    pub static NSStringTransformLatinToKatakana: &'static NSStringTransform;
267}
268
269extern "C" {
270    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformlatintohiragana?language=objc)
271    pub static NSStringTransformLatinToHiragana: &'static NSStringTransform;
272}
273
274extern "C" {
275    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformlatintohangul?language=objc)
276    pub static NSStringTransformLatinToHangul: &'static NSStringTransform;
277}
278
279extern "C" {
280    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformlatintoarabic?language=objc)
281    pub static NSStringTransformLatinToArabic: &'static NSStringTransform;
282}
283
284extern "C" {
285    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformlatintohebrew?language=objc)
286    pub static NSStringTransformLatinToHebrew: &'static NSStringTransform;
287}
288
289extern "C" {
290    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformlatintothai?language=objc)
291    pub static NSStringTransformLatinToThai: &'static NSStringTransform;
292}
293
294extern "C" {
295    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformlatintocyrillic?language=objc)
296    pub static NSStringTransformLatinToCyrillic: &'static NSStringTransform;
297}
298
299extern "C" {
300    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformlatintogreek?language=objc)
301    pub static NSStringTransformLatinToGreek: &'static NSStringTransform;
302}
303
304extern "C" {
305    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformtolatin?language=objc)
306    pub static NSStringTransformToLatin: &'static NSStringTransform;
307}
308
309extern "C" {
310    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformmandarintolatin?language=objc)
311    pub static NSStringTransformMandarinToLatin: &'static NSStringTransform;
312}
313
314extern "C" {
315    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformhiraganatokatakana?language=objc)
316    pub static NSStringTransformHiraganaToKatakana: &'static NSStringTransform;
317}
318
319extern "C" {
320    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformfullwidthtohalfwidth?language=objc)
321    pub static NSStringTransformFullwidthToHalfwidth: &'static NSStringTransform;
322}
323
324extern "C" {
325    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformtoxmlhex?language=objc)
326    pub static NSStringTransformToXMLHex: &'static NSStringTransform;
327}
328
329extern "C" {
330    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformtounicodename?language=objc)
331    pub static NSStringTransformToUnicodeName: &'static NSStringTransform;
332}
333
334extern "C" {
335    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformstripcombiningmarks?language=objc)
336    pub static NSStringTransformStripCombiningMarks: &'static NSStringTransform;
337}
338
339extern "C" {
340    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringtransformstripdiacritics?language=objc)
341    pub static NSStringTransformStripDiacritics: &'static NSStringTransform;
342}
343
344/// NSStringExtensionMethods.
345impl NSString {
346    extern_methods!(
347        #[unsafe(method(substringFromIndex:))]
348        #[unsafe(method_family = none)]
349        pub fn substringFromIndex(&self, from: NSUInteger) -> Retained<NSString>;
350
351        #[unsafe(method(substringToIndex:))]
352        #[unsafe(method_family = none)]
353        pub fn substringToIndex(&self, to: NSUInteger) -> Retained<NSString>;
354
355        #[cfg(feature = "NSRange")]
356        #[unsafe(method(substringWithRange:))]
357        #[unsafe(method_family = none)]
358        pub fn substringWithRange(&self, range: NSRange) -> Retained<NSString>;
359
360        #[cfg(feature = "NSRange")]
361        /// # Safety
362        ///
363        /// `buffer` must be a valid pointer.
364        #[unsafe(method(getCharacters:range:))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn getCharacters_range(&self, buffer: NonNull<unichar>, range: NSRange);
367
368        #[cfg(feature = "NSObjCRuntime")]
369        #[unsafe(method(compare:))]
370        #[unsafe(method_family = none)]
371        pub fn compare(&self, string: &NSString) -> NSComparisonResult;
372
373        #[cfg(feature = "NSObjCRuntime")]
374        #[unsafe(method(compare:options:))]
375        #[unsafe(method_family = none)]
376        pub fn compare_options(
377            &self,
378            string: &NSString,
379            mask: NSStringCompareOptions,
380        ) -> NSComparisonResult;
381
382        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRange"))]
383        #[unsafe(method(compare:options:range:))]
384        #[unsafe(method_family = none)]
385        pub fn compare_options_range(
386            &self,
387            string: &NSString,
388            mask: NSStringCompareOptions,
389            range_of_receiver_to_compare: NSRange,
390        ) -> NSComparisonResult;
391
392        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRange"))]
393        /// # Safety
394        ///
395        /// `locale` should be of the correct type.
396        #[unsafe(method(compare:options:range:locale:))]
397        #[unsafe(method_family = none)]
398        pub unsafe fn compare_options_range_locale(
399            &self,
400            string: &NSString,
401            mask: NSStringCompareOptions,
402            range_of_receiver_to_compare: NSRange,
403            locale: Option<&AnyObject>,
404        ) -> NSComparisonResult;
405
406        #[cfg(feature = "NSObjCRuntime")]
407        #[unsafe(method(caseInsensitiveCompare:))]
408        #[unsafe(method_family = none)]
409        pub fn caseInsensitiveCompare(&self, string: &NSString) -> NSComparisonResult;
410
411        #[cfg(feature = "NSObjCRuntime")]
412        #[unsafe(method(localizedCompare:))]
413        #[unsafe(method_family = none)]
414        pub fn localizedCompare(&self, string: &NSString) -> NSComparisonResult;
415
416        #[cfg(feature = "NSObjCRuntime")]
417        #[unsafe(method(localizedCaseInsensitiveCompare:))]
418        #[unsafe(method_family = none)]
419        pub fn localizedCaseInsensitiveCompare(&self, string: &NSString) -> NSComparisonResult;
420
421        #[cfg(feature = "NSObjCRuntime")]
422        #[unsafe(method(localizedStandardCompare:))]
423        #[unsafe(method_family = none)]
424        pub fn localizedStandardCompare(&self, string: &NSString) -> NSComparisonResult;
425
426        #[unsafe(method(isEqualToString:))]
427        #[unsafe(method_family = none)]
428        pub fn isEqualToString(&self, a_string: &NSString) -> bool;
429
430        #[unsafe(method(hasPrefix:))]
431        #[unsafe(method_family = none)]
432        pub fn hasPrefix(&self, str: &NSString) -> bool;
433
434        #[unsafe(method(hasSuffix:))]
435        #[unsafe(method_family = none)]
436        pub fn hasSuffix(&self, str: &NSString) -> bool;
437
438        #[unsafe(method(commonPrefixWithString:options:))]
439        #[unsafe(method_family = none)]
440        pub fn commonPrefixWithString_options(
441            &self,
442            str: &NSString,
443            mask: NSStringCompareOptions,
444        ) -> Retained<NSString>;
445
446        #[unsafe(method(containsString:))]
447        #[unsafe(method_family = none)]
448        pub fn containsString(&self, str: &NSString) -> bool;
449
450        #[unsafe(method(localizedCaseInsensitiveContainsString:))]
451        #[unsafe(method_family = none)]
452        pub fn localizedCaseInsensitiveContainsString(&self, str: &NSString) -> bool;
453
454        #[unsafe(method(localizedStandardContainsString:))]
455        #[unsafe(method_family = none)]
456        pub fn localizedStandardContainsString(&self, str: &NSString) -> bool;
457
458        #[cfg(feature = "NSRange")]
459        #[unsafe(method(localizedStandardRangeOfString:))]
460        #[unsafe(method_family = none)]
461        pub fn localizedStandardRangeOfString(&self, str: &NSString) -> NSRange;
462
463        #[cfg(feature = "NSRange")]
464        #[unsafe(method(rangeOfString:))]
465        #[unsafe(method_family = none)]
466        pub fn rangeOfString(&self, search_string: &NSString) -> NSRange;
467
468        #[cfg(feature = "NSRange")]
469        #[unsafe(method(rangeOfString:options:))]
470        #[unsafe(method_family = none)]
471        pub fn rangeOfString_options(
472            &self,
473            search_string: &NSString,
474            mask: NSStringCompareOptions,
475        ) -> NSRange;
476
477        #[cfg(feature = "NSRange")]
478        #[unsafe(method(rangeOfString:options:range:))]
479        #[unsafe(method_family = none)]
480        pub fn rangeOfString_options_range(
481            &self,
482            search_string: &NSString,
483            mask: NSStringCompareOptions,
484            range_of_receiver_to_search: NSRange,
485        ) -> NSRange;
486
487        #[cfg(all(feature = "NSLocale", feature = "NSRange"))]
488        #[unsafe(method(rangeOfString:options:range:locale:))]
489        #[unsafe(method_family = none)]
490        pub fn rangeOfString_options_range_locale(
491            &self,
492            search_string: &NSString,
493            mask: NSStringCompareOptions,
494            range_of_receiver_to_search: NSRange,
495            locale: Option<&NSLocale>,
496        ) -> NSRange;
497
498        #[cfg(all(feature = "NSCharacterSet", feature = "NSRange"))]
499        #[unsafe(method(rangeOfCharacterFromSet:))]
500        #[unsafe(method_family = none)]
501        pub fn rangeOfCharacterFromSet(&self, search_set: &NSCharacterSet) -> NSRange;
502
503        #[cfg(all(feature = "NSCharacterSet", feature = "NSRange"))]
504        #[unsafe(method(rangeOfCharacterFromSet:options:))]
505        #[unsafe(method_family = none)]
506        pub fn rangeOfCharacterFromSet_options(
507            &self,
508            search_set: &NSCharacterSet,
509            mask: NSStringCompareOptions,
510        ) -> NSRange;
511
512        #[cfg(all(feature = "NSCharacterSet", feature = "NSRange"))]
513        #[unsafe(method(rangeOfCharacterFromSet:options:range:))]
514        #[unsafe(method_family = none)]
515        pub fn rangeOfCharacterFromSet_options_range(
516            &self,
517            search_set: &NSCharacterSet,
518            mask: NSStringCompareOptions,
519            range_of_receiver_to_search: NSRange,
520        ) -> NSRange;
521
522        #[cfg(feature = "NSRange")]
523        #[unsafe(method(rangeOfComposedCharacterSequenceAtIndex:))]
524        #[unsafe(method_family = none)]
525        pub fn rangeOfComposedCharacterSequenceAtIndex(&self, index: NSUInteger) -> NSRange;
526
527        #[cfg(feature = "NSRange")]
528        #[unsafe(method(rangeOfComposedCharacterSequencesForRange:))]
529        #[unsafe(method_family = none)]
530        pub fn rangeOfComposedCharacterSequencesForRange(&self, range: NSRange) -> NSRange;
531
532        #[unsafe(method(stringByAppendingString:))]
533        #[unsafe(method_family = none)]
534        pub fn stringByAppendingString(&self, a_string: &NSString) -> Retained<NSString>;
535
536        #[unsafe(method(doubleValue))]
537        #[unsafe(method_family = none)]
538        pub fn doubleValue(&self) -> c_double;
539
540        #[unsafe(method(floatValue))]
541        #[unsafe(method_family = none)]
542        pub fn floatValue(&self) -> c_float;
543
544        #[unsafe(method(intValue))]
545        #[unsafe(method_family = none)]
546        pub fn intValue(&self) -> c_int;
547
548        #[unsafe(method(integerValue))]
549        #[unsafe(method_family = none)]
550        pub fn integerValue(&self) -> NSInteger;
551
552        #[unsafe(method(longLongValue))]
553        #[unsafe(method_family = none)]
554        pub fn longLongValue(&self) -> c_longlong;
555
556        #[unsafe(method(boolValue))]
557        #[unsafe(method_family = none)]
558        pub fn boolValue(&self) -> bool;
559
560        #[unsafe(method(uppercaseString))]
561        #[unsafe(method_family = none)]
562        pub fn uppercaseString(&self) -> Retained<NSString>;
563
564        #[unsafe(method(lowercaseString))]
565        #[unsafe(method_family = none)]
566        pub fn lowercaseString(&self) -> Retained<NSString>;
567
568        #[unsafe(method(capitalizedString))]
569        #[unsafe(method_family = none)]
570        pub fn capitalizedString(&self) -> Retained<NSString>;
571
572        #[unsafe(method(localizedUppercaseString))]
573        #[unsafe(method_family = none)]
574        pub fn localizedUppercaseString(&self) -> Retained<NSString>;
575
576        #[unsafe(method(localizedLowercaseString))]
577        #[unsafe(method_family = none)]
578        pub fn localizedLowercaseString(&self) -> Retained<NSString>;
579
580        #[unsafe(method(localizedCapitalizedString))]
581        #[unsafe(method_family = none)]
582        pub fn localizedCapitalizedString(&self) -> Retained<NSString>;
583
584        #[cfg(feature = "NSLocale")]
585        #[unsafe(method(uppercaseStringWithLocale:))]
586        #[unsafe(method_family = none)]
587        pub fn uppercaseStringWithLocale(&self, locale: Option<&NSLocale>) -> Retained<NSString>;
588
589        #[cfg(feature = "NSLocale")]
590        #[unsafe(method(lowercaseStringWithLocale:))]
591        #[unsafe(method_family = none)]
592        pub fn lowercaseStringWithLocale(&self, locale: Option<&NSLocale>) -> Retained<NSString>;
593
594        #[cfg(feature = "NSLocale")]
595        #[unsafe(method(capitalizedStringWithLocale:))]
596        #[unsafe(method_family = none)]
597        pub fn capitalizedStringWithLocale(&self, locale: Option<&NSLocale>) -> Retained<NSString>;
598
599        #[cfg(feature = "NSRange")]
600        /// # Safety
601        ///
602        /// - `start_ptr` must be a valid pointer or null.
603        /// - `line_end_ptr` must be a valid pointer or null.
604        /// - `contents_end_ptr` must be a valid pointer or null.
605        #[unsafe(method(getLineStart:end:contentsEnd:forRange:))]
606        #[unsafe(method_family = none)]
607        pub unsafe fn getLineStart_end_contentsEnd_forRange(
608            &self,
609            start_ptr: *mut NSUInteger,
610            line_end_ptr: *mut NSUInteger,
611            contents_end_ptr: *mut NSUInteger,
612            range: NSRange,
613        );
614
615        #[cfg(feature = "NSRange")]
616        #[unsafe(method(lineRangeForRange:))]
617        #[unsafe(method_family = none)]
618        pub fn lineRangeForRange(&self, range: NSRange) -> NSRange;
619
620        #[cfg(feature = "NSRange")]
621        /// # Safety
622        ///
623        /// - `start_ptr` must be a valid pointer or null.
624        /// - `par_end_ptr` must be a valid pointer or null.
625        /// - `contents_end_ptr` must be a valid pointer or null.
626        #[unsafe(method(getParagraphStart:end:contentsEnd:forRange:))]
627        #[unsafe(method_family = none)]
628        pub unsafe fn getParagraphStart_end_contentsEnd_forRange(
629            &self,
630            start_ptr: *mut NSUInteger,
631            par_end_ptr: *mut NSUInteger,
632            contents_end_ptr: *mut NSUInteger,
633            range: NSRange,
634        );
635
636        #[cfg(feature = "NSRange")]
637        #[unsafe(method(paragraphRangeForRange:))]
638        #[unsafe(method_family = none)]
639        pub fn paragraphRangeForRange(&self, range: NSRange) -> NSRange;
640
641        #[cfg(all(feature = "NSRange", feature = "block2"))]
642        #[unsafe(method(enumerateSubstringsInRange:options:usingBlock:))]
643        #[unsafe(method_family = none)]
644        pub fn enumerateSubstringsInRange_options_usingBlock(
645            &self,
646            range: NSRange,
647            opts: NSStringEnumerationOptions,
648            block: &block2::DynBlock<dyn Fn(*mut NSString, NSRange, NSRange, NonNull<Bool>)>,
649        );
650
651        #[cfg(feature = "block2")]
652        #[unsafe(method(enumerateLinesUsingBlock:))]
653        #[unsafe(method_family = none)]
654        pub fn enumerateLinesUsingBlock(
655            &self,
656            block: &block2::DynBlock<dyn Fn(NonNull<NSString>, NonNull<Bool>)>,
657        );
658
659        #[unsafe(method(UTF8String))]
660        #[unsafe(method_family = none)]
661        pub fn UTF8String(&self) -> *const c_char;
662
663        #[unsafe(method(fastestEncoding))]
664        #[unsafe(method_family = none)]
665        pub fn fastestEncoding(&self) -> NSStringEncoding;
666
667        #[unsafe(method(smallestEncoding))]
668        #[unsafe(method_family = none)]
669        pub fn smallestEncoding(&self) -> NSStringEncoding;
670
671        #[cfg(feature = "NSData")]
672        #[unsafe(method(dataUsingEncoding:allowLossyConversion:))]
673        #[unsafe(method_family = none)]
674        pub fn dataUsingEncoding_allowLossyConversion(
675            &self,
676            encoding: NSStringEncoding,
677            lossy: bool,
678        ) -> Option<Retained<NSData>>;
679
680        #[cfg(feature = "NSData")]
681        #[unsafe(method(dataUsingEncoding:))]
682        #[unsafe(method_family = none)]
683        pub fn dataUsingEncoding(&self, encoding: NSStringEncoding) -> Option<Retained<NSData>>;
684
685        #[unsafe(method(canBeConvertedToEncoding:))]
686        #[unsafe(method_family = none)]
687        pub fn canBeConvertedToEncoding(&self, encoding: NSStringEncoding) -> bool;
688
689        #[unsafe(method(cStringUsingEncoding:))]
690        #[unsafe(method_family = none)]
691        pub fn cStringUsingEncoding(&self, encoding: NSStringEncoding) -> *const c_char;
692
693        /// # Safety
694        ///
695        /// `buffer` must be a valid pointer.
696        #[unsafe(method(getCString:maxLength:encoding:))]
697        #[unsafe(method_family = none)]
698        pub unsafe fn getCString_maxLength_encoding(
699            &self,
700            buffer: NonNull<c_char>,
701            max_buffer_count: NSUInteger,
702            encoding: NSStringEncoding,
703        ) -> bool;
704
705        #[cfg(feature = "NSRange")]
706        /// # Safety
707        ///
708        /// - `buffer` must be a valid pointer or null.
709        /// - `used_buffer_count` must be a valid pointer or null.
710        /// - `leftover` must be a valid pointer or null.
711        #[unsafe(method(getBytes:maxLength:usedLength:encoding:options:range:remainingRange:))]
712        #[unsafe(method_family = none)]
713        pub unsafe fn getBytes_maxLength_usedLength_encoding_options_range_remainingRange(
714            &self,
715            buffer: *mut c_void,
716            max_buffer_count: NSUInteger,
717            used_buffer_count: *mut NSUInteger,
718            encoding: NSStringEncoding,
719            options: NSStringEncodingConversionOptions,
720            range: NSRange,
721            leftover: NSRangePointer,
722        ) -> bool;
723
724        #[unsafe(method(maximumLengthOfBytesUsingEncoding:))]
725        #[unsafe(method_family = none)]
726        pub fn maximumLengthOfBytesUsingEncoding(&self, enc: NSStringEncoding) -> NSUInteger;
727
728        #[unsafe(method(lengthOfBytesUsingEncoding:))]
729        #[unsafe(method_family = none)]
730        pub fn lengthOfBytesUsingEncoding(&self, enc: NSStringEncoding) -> NSUInteger;
731
732        #[unsafe(method(availableStringEncodings))]
733        #[unsafe(method_family = none)]
734        pub fn availableStringEncodings() -> NonNull<NSStringEncoding>;
735
736        #[unsafe(method(localizedNameOfStringEncoding:))]
737        #[unsafe(method_family = none)]
738        pub fn localizedNameOfStringEncoding(encoding: NSStringEncoding) -> Retained<NSString>;
739
740        #[unsafe(method(defaultCStringEncoding))]
741        #[unsafe(method_family = none)]
742        pub fn defaultCStringEncoding() -> NSStringEncoding;
743
744        #[unsafe(method(decomposedStringWithCanonicalMapping))]
745        #[unsafe(method_family = none)]
746        pub fn decomposedStringWithCanonicalMapping(&self) -> Retained<NSString>;
747
748        #[unsafe(method(precomposedStringWithCanonicalMapping))]
749        #[unsafe(method_family = none)]
750        pub fn precomposedStringWithCanonicalMapping(&self) -> Retained<NSString>;
751
752        #[unsafe(method(decomposedStringWithCompatibilityMapping))]
753        #[unsafe(method_family = none)]
754        pub fn decomposedStringWithCompatibilityMapping(&self) -> Retained<NSString>;
755
756        #[unsafe(method(precomposedStringWithCompatibilityMapping))]
757        #[unsafe(method_family = none)]
758        pub fn precomposedStringWithCompatibilityMapping(&self) -> Retained<NSString>;
759
760        #[cfg(feature = "NSArray")]
761        #[unsafe(method(componentsSeparatedByString:))]
762        #[unsafe(method_family = none)]
763        pub fn componentsSeparatedByString(
764            &self,
765            separator: &NSString,
766        ) -> Retained<NSArray<NSString>>;
767
768        #[cfg(all(feature = "NSArray", feature = "NSCharacterSet"))]
769        #[unsafe(method(componentsSeparatedByCharactersInSet:))]
770        #[unsafe(method_family = none)]
771        pub fn componentsSeparatedByCharactersInSet(
772            &self,
773            separator: &NSCharacterSet,
774        ) -> Retained<NSArray<NSString>>;
775
776        #[cfg(feature = "NSCharacterSet")]
777        #[unsafe(method(stringByTrimmingCharactersInSet:))]
778        #[unsafe(method_family = none)]
779        pub fn stringByTrimmingCharactersInSet(&self, set: &NSCharacterSet) -> Retained<NSString>;
780
781        #[unsafe(method(stringByPaddingToLength:withString:startingAtIndex:))]
782        #[unsafe(method_family = none)]
783        pub fn stringByPaddingToLength_withString_startingAtIndex(
784            &self,
785            new_length: NSUInteger,
786            pad_string: &NSString,
787            pad_index: NSUInteger,
788        ) -> Retained<NSString>;
789
790        #[cfg(feature = "NSLocale")]
791        #[unsafe(method(stringByFoldingWithOptions:locale:))]
792        #[unsafe(method_family = none)]
793        pub fn stringByFoldingWithOptions_locale(
794            &self,
795            options: NSStringCompareOptions,
796            locale: Option<&NSLocale>,
797        ) -> Retained<NSString>;
798
799        #[cfg(feature = "NSRange")]
800        #[unsafe(method(stringByReplacingOccurrencesOfString:withString:options:range:))]
801        #[unsafe(method_family = none)]
802        pub fn stringByReplacingOccurrencesOfString_withString_options_range(
803            &self,
804            target: &NSString,
805            replacement: &NSString,
806            options: NSStringCompareOptions,
807            search_range: NSRange,
808        ) -> Retained<NSString>;
809
810        #[unsafe(method(stringByReplacingOccurrencesOfString:withString:))]
811        #[unsafe(method_family = none)]
812        pub fn stringByReplacingOccurrencesOfString_withString(
813            &self,
814            target: &NSString,
815            replacement: &NSString,
816        ) -> Retained<NSString>;
817
818        #[cfg(feature = "NSRange")]
819        #[unsafe(method(stringByReplacingCharactersInRange:withString:))]
820        #[unsafe(method_family = none)]
821        pub fn stringByReplacingCharactersInRange_withString(
822            &self,
823            range: NSRange,
824            replacement: &NSString,
825        ) -> Retained<NSString>;
826
827        #[unsafe(method(stringByApplyingTransform:reverse:))]
828        #[unsafe(method_family = none)]
829        pub fn stringByApplyingTransform_reverse(
830            &self,
831            transform: &NSStringTransform,
832            reverse: bool,
833        ) -> Option<Retained<NSString>>;
834
835        #[cfg(all(feature = "NSError", feature = "NSURL"))]
836        #[unsafe(method(writeToURL:atomically:encoding:error:_))]
837        #[unsafe(method_family = none)]
838        pub fn writeToURL_atomically_encoding_error(
839            &self,
840            url: &NSURL,
841            use_auxiliary_file: bool,
842            enc: NSStringEncoding,
843        ) -> Result<(), Retained<NSError>>;
844
845        #[cfg(feature = "NSError")]
846        #[unsafe(method(writeToFile:atomically:encoding:error:_))]
847        #[unsafe(method_family = none)]
848        pub fn writeToFile_atomically_encoding_error(
849            &self,
850            path: &NSString,
851            use_auxiliary_file: bool,
852            enc: NSStringEncoding,
853        ) -> Result<(), Retained<NSError>>;
854
855        #[unsafe(method(description))]
856        #[unsafe(method_family = none)]
857        pub fn description(&self) -> Retained<NSString>;
858
859        #[unsafe(method(hash))]
860        #[unsafe(method_family = none)]
861        pub fn hash(&self) -> NSUInteger;
862
863        /// # Safety
864        ///
865        /// `characters` must be a valid pointer.
866        #[unsafe(method(initWithCharactersNoCopy:length:freeWhenDone:))]
867        #[unsafe(method_family = init)]
868        pub unsafe fn initWithCharactersNoCopy_length_freeWhenDone(
869            this: Allocated<Self>,
870            characters: NonNull<unichar>,
871            length: NSUInteger,
872            free_buffer: bool,
873        ) -> Retained<Self>;
874
875        #[cfg(feature = "block2")]
876        /// # Safety
877        ///
878        /// `chars` must be a valid pointer.
879        #[unsafe(method(initWithCharactersNoCopy:length:deallocator:))]
880        #[unsafe(method_family = init)]
881        pub unsafe fn initWithCharactersNoCopy_length_deallocator(
882            this: Allocated<Self>,
883            chars: NonNull<unichar>,
884            len: NSUInteger,
885            deallocator: Option<&block2::DynBlock<dyn Fn(NonNull<unichar>, NSUInteger)>>,
886        ) -> Retained<Self>;
887
888        /// # Safety
889        ///
890        /// `characters` must be a valid pointer.
891        #[unsafe(method(initWithCharacters:length:))]
892        #[unsafe(method_family = init)]
893        pub unsafe fn initWithCharacters_length(
894            this: Allocated<Self>,
895            characters: NonNull<unichar>,
896            length: NSUInteger,
897        ) -> Retained<Self>;
898
899        /// # Safety
900        ///
901        /// `null_terminated_c_string` must be a valid pointer.
902        #[unsafe(method(initWithUTF8String:))]
903        #[unsafe(method_family = init)]
904        pub unsafe fn initWithUTF8String(
905            this: Allocated<Self>,
906            null_terminated_c_string: NonNull<c_char>,
907        ) -> Option<Retained<Self>>;
908
909        #[unsafe(method(initWithString:))]
910        #[unsafe(method_family = init)]
911        pub fn initWithString(this: Allocated<Self>, a_string: &NSString) -> Retained<Self>;
912
913        #[cfg(feature = "NSData")]
914        #[unsafe(method(initWithData:encoding:))]
915        #[unsafe(method_family = init)]
916        pub fn initWithData_encoding(
917            this: Allocated<Self>,
918            data: &NSData,
919            encoding: NSStringEncoding,
920        ) -> Option<Retained<Self>>;
921
922        /// # Safety
923        ///
924        /// `bytes` must be a valid pointer.
925        #[unsafe(method(initWithBytes:length:encoding:))]
926        #[unsafe(method_family = init)]
927        pub unsafe fn initWithBytes_length_encoding(
928            this: Allocated<Self>,
929            bytes: NonNull<c_void>,
930            len: NSUInteger,
931            encoding: NSStringEncoding,
932        ) -> Option<Retained<Self>>;
933
934        /// # Safety
935        ///
936        /// `bytes` must be a valid pointer.
937        #[unsafe(method(initWithBytesNoCopy:length:encoding:freeWhenDone:))]
938        #[unsafe(method_family = init)]
939        pub unsafe fn initWithBytesNoCopy_length_encoding_freeWhenDone(
940            this: Allocated<Self>,
941            bytes: NonNull<c_void>,
942            len: NSUInteger,
943            encoding: NSStringEncoding,
944            free_buffer: bool,
945        ) -> Option<Retained<Self>>;
946
947        #[cfg(feature = "block2")]
948        /// # Safety
949        ///
950        /// `bytes` must be a valid pointer.
951        #[unsafe(method(initWithBytesNoCopy:length:encoding:deallocator:))]
952        #[unsafe(method_family = init)]
953        pub unsafe fn initWithBytesNoCopy_length_encoding_deallocator(
954            this: Allocated<Self>,
955            bytes: NonNull<c_void>,
956            len: NSUInteger,
957            encoding: NSStringEncoding,
958            deallocator: Option<&block2::DynBlock<dyn Fn(NonNull<c_void>, NSUInteger)>>,
959        ) -> Option<Retained<Self>>;
960
961        #[unsafe(method(string))]
962        #[unsafe(method_family = none)]
963        pub fn string() -> Retained<Self>;
964
965        #[unsafe(method(stringWithString:))]
966        #[unsafe(method_family = none)]
967        pub fn stringWithString(string: &NSString) -> Retained<Self>;
968
969        /// # Safety
970        ///
971        /// `characters` must be a valid pointer.
972        #[unsafe(method(stringWithCharacters:length:))]
973        #[unsafe(method_family = none)]
974        pub unsafe fn stringWithCharacters_length(
975            characters: NonNull<unichar>,
976            length: NSUInteger,
977        ) -> Retained<Self>;
978
979        /// # Safety
980        ///
981        /// `null_terminated_c_string` must be a valid pointer.
982        #[unsafe(method(stringWithUTF8String:))]
983        #[unsafe(method_family = none)]
984        pub unsafe fn stringWithUTF8String(
985            null_terminated_c_string: NonNull<c_char>,
986        ) -> Option<Retained<Self>>;
987
988        /// # Safety
989        ///
990        /// `null_terminated_c_string` must be a valid pointer.
991        #[unsafe(method(initWithCString:encoding:))]
992        #[unsafe(method_family = init)]
993        pub unsafe fn initWithCString_encoding(
994            this: Allocated<Self>,
995            null_terminated_c_string: NonNull<c_char>,
996            encoding: NSStringEncoding,
997        ) -> Option<Retained<Self>>;
998
999        /// # Safety
1000        ///
1001        /// `c_string` must be a valid pointer.
1002        #[unsafe(method(stringWithCString:encoding:))]
1003        #[unsafe(method_family = none)]
1004        pub unsafe fn stringWithCString_encoding(
1005            c_string: NonNull<c_char>,
1006            enc: NSStringEncoding,
1007        ) -> Option<Retained<Self>>;
1008
1009        #[cfg(all(feature = "NSError", feature = "NSURL"))]
1010        #[unsafe(method(initWithContentsOfURL:encoding:error:_))]
1011        #[unsafe(method_family = init)]
1012        pub fn initWithContentsOfURL_encoding_error(
1013            this: Allocated<Self>,
1014            url: &NSURL,
1015            enc: NSStringEncoding,
1016        ) -> Result<Retained<Self>, Retained<NSError>>;
1017
1018        #[cfg(feature = "NSError")]
1019        #[unsafe(method(initWithContentsOfFile:encoding:error:_))]
1020        #[unsafe(method_family = init)]
1021        pub fn initWithContentsOfFile_encoding_error(
1022            this: Allocated<Self>,
1023            path: &NSString,
1024            enc: NSStringEncoding,
1025        ) -> Result<Retained<Self>, Retained<NSError>>;
1026
1027        #[cfg(all(feature = "NSError", feature = "NSURL"))]
1028        #[unsafe(method(stringWithContentsOfURL:encoding:error:_))]
1029        #[unsafe(method_family = none)]
1030        pub fn stringWithContentsOfURL_encoding_error(
1031            url: &NSURL,
1032            enc: NSStringEncoding,
1033        ) -> Result<Retained<Self>, Retained<NSError>>;
1034
1035        #[cfg(feature = "NSError")]
1036        #[unsafe(method(stringWithContentsOfFile:encoding:error:_))]
1037        #[unsafe(method_family = none)]
1038        pub fn stringWithContentsOfFile_encoding_error(
1039            path: &NSString,
1040            enc: NSStringEncoding,
1041        ) -> Result<Retained<Self>, Retained<NSError>>;
1042
1043        #[cfg(all(feature = "NSError", feature = "NSURL"))]
1044        /// # Safety
1045        ///
1046        /// `enc` must be a valid pointer or null.
1047        #[unsafe(method(initWithContentsOfURL:usedEncoding:error:_))]
1048        #[unsafe(method_family = init)]
1049        pub unsafe fn initWithContentsOfURL_usedEncoding_error(
1050            this: Allocated<Self>,
1051            url: &NSURL,
1052            enc: *mut NSStringEncoding,
1053        ) -> Result<Retained<Self>, Retained<NSError>>;
1054
1055        #[cfg(feature = "NSError")]
1056        /// # Safety
1057        ///
1058        /// `enc` must be a valid pointer or null.
1059        #[unsafe(method(initWithContentsOfFile:usedEncoding:error:_))]
1060        #[unsafe(method_family = init)]
1061        pub unsafe fn initWithContentsOfFile_usedEncoding_error(
1062            this: Allocated<Self>,
1063            path: &NSString,
1064            enc: *mut NSStringEncoding,
1065        ) -> Result<Retained<Self>, Retained<NSError>>;
1066
1067        #[cfg(all(feature = "NSError", feature = "NSURL"))]
1068        /// # Safety
1069        ///
1070        /// `enc` must be a valid pointer or null.
1071        #[unsafe(method(stringWithContentsOfURL:usedEncoding:error:_))]
1072        #[unsafe(method_family = none)]
1073        pub unsafe fn stringWithContentsOfURL_usedEncoding_error(
1074            url: &NSURL,
1075            enc: *mut NSStringEncoding,
1076        ) -> Result<Retained<Self>, Retained<NSError>>;
1077
1078        #[cfg(feature = "NSError")]
1079        /// # Safety
1080        ///
1081        /// `enc` must be a valid pointer or null.
1082        #[unsafe(method(stringWithContentsOfFile:usedEncoding:error:_))]
1083        #[unsafe(method_family = none)]
1084        pub unsafe fn stringWithContentsOfFile_usedEncoding_error(
1085            path: &NSString,
1086            enc: *mut NSStringEncoding,
1087        ) -> Result<Retained<Self>, Retained<NSError>>;
1088    );
1089}
1090
1091/// Methods declared on superclass `NSString`.
1092///
1093/// NSStringExtensionMethods.
1094impl NSMutableString {
1095    extern_methods!(
1096        /// # Safety
1097        ///
1098        /// `characters` must be a valid pointer.
1099        #[unsafe(method(initWithCharactersNoCopy:length:freeWhenDone:))]
1100        #[unsafe(method_family = init)]
1101        pub unsafe fn initWithCharactersNoCopy_length_freeWhenDone(
1102            this: Allocated<Self>,
1103            characters: NonNull<unichar>,
1104            length: NSUInteger,
1105            free_buffer: bool,
1106        ) -> Retained<Self>;
1107
1108        #[cfg(feature = "block2")]
1109        /// # Safety
1110        ///
1111        /// `chars` must be a valid pointer.
1112        #[unsafe(method(initWithCharactersNoCopy:length:deallocator:))]
1113        #[unsafe(method_family = init)]
1114        pub unsafe fn initWithCharactersNoCopy_length_deallocator(
1115            this: Allocated<Self>,
1116            chars: NonNull<unichar>,
1117            len: NSUInteger,
1118            deallocator: Option<&block2::DynBlock<dyn Fn(NonNull<unichar>, NSUInteger)>>,
1119        ) -> Retained<Self>;
1120
1121        /// # Safety
1122        ///
1123        /// `characters` must be a valid pointer.
1124        #[unsafe(method(initWithCharacters:length:))]
1125        #[unsafe(method_family = init)]
1126        pub unsafe fn initWithCharacters_length(
1127            this: Allocated<Self>,
1128            characters: NonNull<unichar>,
1129            length: NSUInteger,
1130        ) -> Retained<Self>;
1131
1132        /// # Safety
1133        ///
1134        /// `null_terminated_c_string` must be a valid pointer.
1135        #[unsafe(method(initWithUTF8String:))]
1136        #[unsafe(method_family = init)]
1137        pub unsafe fn initWithUTF8String(
1138            this: Allocated<Self>,
1139            null_terminated_c_string: NonNull<c_char>,
1140        ) -> Option<Retained<Self>>;
1141
1142        #[unsafe(method(initWithString:))]
1143        #[unsafe(method_family = init)]
1144        pub fn initWithString(this: Allocated<Self>, a_string: &NSString) -> Retained<Self>;
1145
1146        #[cfg(feature = "NSData")]
1147        #[unsafe(method(initWithData:encoding:))]
1148        #[unsafe(method_family = init)]
1149        pub fn initWithData_encoding(
1150            this: Allocated<Self>,
1151            data: &NSData,
1152            encoding: NSStringEncoding,
1153        ) -> Option<Retained<Self>>;
1154
1155        /// # Safety
1156        ///
1157        /// `bytes` must be a valid pointer.
1158        #[unsafe(method(initWithBytes:length:encoding:))]
1159        #[unsafe(method_family = init)]
1160        pub unsafe fn initWithBytes_length_encoding(
1161            this: Allocated<Self>,
1162            bytes: NonNull<c_void>,
1163            len: NSUInteger,
1164            encoding: NSStringEncoding,
1165        ) -> Option<Retained<Self>>;
1166
1167        /// # Safety
1168        ///
1169        /// `bytes` must be a valid pointer.
1170        #[unsafe(method(initWithBytesNoCopy:length:encoding:freeWhenDone:))]
1171        #[unsafe(method_family = init)]
1172        pub unsafe fn initWithBytesNoCopy_length_encoding_freeWhenDone(
1173            this: Allocated<Self>,
1174            bytes: NonNull<c_void>,
1175            len: NSUInteger,
1176            encoding: NSStringEncoding,
1177            free_buffer: bool,
1178        ) -> Option<Retained<Self>>;
1179
1180        #[cfg(feature = "block2")]
1181        /// # Safety
1182        ///
1183        /// `bytes` must be a valid pointer.
1184        #[unsafe(method(initWithBytesNoCopy:length:encoding:deallocator:))]
1185        #[unsafe(method_family = init)]
1186        pub unsafe fn initWithBytesNoCopy_length_encoding_deallocator(
1187            this: Allocated<Self>,
1188            bytes: NonNull<c_void>,
1189            len: NSUInteger,
1190            encoding: NSStringEncoding,
1191            deallocator: Option<&block2::DynBlock<dyn Fn(NonNull<c_void>, NSUInteger)>>,
1192        ) -> Option<Retained<Self>>;
1193
1194        #[unsafe(method(string))]
1195        #[unsafe(method_family = none)]
1196        pub fn string() -> Retained<Self>;
1197
1198        #[unsafe(method(stringWithString:))]
1199        #[unsafe(method_family = none)]
1200        pub fn stringWithString(string: &NSString) -> Retained<Self>;
1201
1202        /// # Safety
1203        ///
1204        /// `characters` must be a valid pointer.
1205        #[unsafe(method(stringWithCharacters:length:))]
1206        #[unsafe(method_family = none)]
1207        pub unsafe fn stringWithCharacters_length(
1208            characters: NonNull<unichar>,
1209            length: NSUInteger,
1210        ) -> Retained<Self>;
1211
1212        /// # Safety
1213        ///
1214        /// `null_terminated_c_string` must be a valid pointer.
1215        #[unsafe(method(stringWithUTF8String:))]
1216        #[unsafe(method_family = none)]
1217        pub unsafe fn stringWithUTF8String(
1218            null_terminated_c_string: NonNull<c_char>,
1219        ) -> Option<Retained<Self>>;
1220
1221        /// # Safety
1222        ///
1223        /// `null_terminated_c_string` must be a valid pointer.
1224        #[unsafe(method(initWithCString:encoding:))]
1225        #[unsafe(method_family = init)]
1226        pub unsafe fn initWithCString_encoding(
1227            this: Allocated<Self>,
1228            null_terminated_c_string: NonNull<c_char>,
1229            encoding: NSStringEncoding,
1230        ) -> Option<Retained<Self>>;
1231
1232        /// # Safety
1233        ///
1234        /// `c_string` must be a valid pointer.
1235        #[unsafe(method(stringWithCString:encoding:))]
1236        #[unsafe(method_family = none)]
1237        pub unsafe fn stringWithCString_encoding(
1238            c_string: NonNull<c_char>,
1239            enc: NSStringEncoding,
1240        ) -> Option<Retained<Self>>;
1241
1242        #[cfg(all(feature = "NSError", feature = "NSURL"))]
1243        #[unsafe(method(initWithContentsOfURL:encoding:error:_))]
1244        #[unsafe(method_family = init)]
1245        pub fn initWithContentsOfURL_encoding_error(
1246            this: Allocated<Self>,
1247            url: &NSURL,
1248            enc: NSStringEncoding,
1249        ) -> Result<Retained<Self>, Retained<NSError>>;
1250
1251        #[cfg(feature = "NSError")]
1252        #[unsafe(method(initWithContentsOfFile:encoding:error:_))]
1253        #[unsafe(method_family = init)]
1254        pub fn initWithContentsOfFile_encoding_error(
1255            this: Allocated<Self>,
1256            path: &NSString,
1257            enc: NSStringEncoding,
1258        ) -> Result<Retained<Self>, Retained<NSError>>;
1259
1260        #[cfg(all(feature = "NSError", feature = "NSURL"))]
1261        #[unsafe(method(stringWithContentsOfURL:encoding:error:_))]
1262        #[unsafe(method_family = none)]
1263        pub fn stringWithContentsOfURL_encoding_error(
1264            url: &NSURL,
1265            enc: NSStringEncoding,
1266        ) -> Result<Retained<Self>, Retained<NSError>>;
1267
1268        #[cfg(feature = "NSError")]
1269        #[unsafe(method(stringWithContentsOfFile:encoding:error:_))]
1270        #[unsafe(method_family = none)]
1271        pub fn stringWithContentsOfFile_encoding_error(
1272            path: &NSString,
1273            enc: NSStringEncoding,
1274        ) -> Result<Retained<Self>, Retained<NSError>>;
1275
1276        #[cfg(all(feature = "NSError", feature = "NSURL"))]
1277        /// # Safety
1278        ///
1279        /// `enc` must be a valid pointer or null.
1280        #[unsafe(method(initWithContentsOfURL:usedEncoding:error:_))]
1281        #[unsafe(method_family = init)]
1282        pub unsafe fn initWithContentsOfURL_usedEncoding_error(
1283            this: Allocated<Self>,
1284            url: &NSURL,
1285            enc: *mut NSStringEncoding,
1286        ) -> Result<Retained<Self>, Retained<NSError>>;
1287
1288        #[cfg(feature = "NSError")]
1289        /// # Safety
1290        ///
1291        /// `enc` must be a valid pointer or null.
1292        #[unsafe(method(initWithContentsOfFile:usedEncoding:error:_))]
1293        #[unsafe(method_family = init)]
1294        pub unsafe fn initWithContentsOfFile_usedEncoding_error(
1295            this: Allocated<Self>,
1296            path: &NSString,
1297            enc: *mut NSStringEncoding,
1298        ) -> Result<Retained<Self>, Retained<NSError>>;
1299
1300        #[cfg(all(feature = "NSError", feature = "NSURL"))]
1301        /// # Safety
1302        ///
1303        /// `enc` must be a valid pointer or null.
1304        #[unsafe(method(stringWithContentsOfURL:usedEncoding:error:_))]
1305        #[unsafe(method_family = none)]
1306        pub unsafe fn stringWithContentsOfURL_usedEncoding_error(
1307            url: &NSURL,
1308            enc: *mut NSStringEncoding,
1309        ) -> Result<Retained<Self>, Retained<NSError>>;
1310
1311        #[cfg(feature = "NSError")]
1312        /// # Safety
1313        ///
1314        /// `enc` must be a valid pointer or null.
1315        #[unsafe(method(stringWithContentsOfFile:usedEncoding:error:_))]
1316        #[unsafe(method_family = none)]
1317        pub unsafe fn stringWithContentsOfFile_usedEncoding_error(
1318            path: &NSString,
1319            enc: *mut NSStringEncoding,
1320        ) -> Result<Retained<Self>, Retained<NSError>>;
1321    );
1322}
1323
1324/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringencodingdetectionoptionskey?language=objc)
1325// NS_TYPED_ENUM
1326pub type NSStringEncodingDetectionOptionsKey = NSString;
1327
1328extern "C" {
1329    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringencodingdetectionsuggestedencodingskey?language=objc)
1330    pub static NSStringEncodingDetectionSuggestedEncodingsKey:
1331        &'static NSStringEncodingDetectionOptionsKey;
1332}
1333
1334extern "C" {
1335    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringencodingdetectiondisallowedencodingskey?language=objc)
1336    pub static NSStringEncodingDetectionDisallowedEncodingsKey:
1337        &'static NSStringEncodingDetectionOptionsKey;
1338}
1339
1340extern "C" {
1341    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringencodingdetectionuseonlysuggestedencodingskey?language=objc)
1342    pub static NSStringEncodingDetectionUseOnlySuggestedEncodingsKey:
1343        &'static NSStringEncodingDetectionOptionsKey;
1344}
1345
1346extern "C" {
1347    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringencodingdetectionallowlossykey?language=objc)
1348    pub static NSStringEncodingDetectionAllowLossyKey: &'static NSStringEncodingDetectionOptionsKey;
1349}
1350
1351extern "C" {
1352    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringencodingdetectionfromwindowskey?language=objc)
1353    pub static NSStringEncodingDetectionFromWindowsKey:
1354        &'static NSStringEncodingDetectionOptionsKey;
1355}
1356
1357extern "C" {
1358    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringencodingdetectionlossysubstitutionkey?language=objc)
1359    pub static NSStringEncodingDetectionLossySubstitutionKey:
1360        &'static NSStringEncodingDetectionOptionsKey;
1361}
1362
1363extern "C" {
1364    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsstringencodingdetectionlikelylanguagekey?language=objc)
1365    pub static NSStringEncodingDetectionLikelyLanguageKey:
1366        &'static NSStringEncodingDetectionOptionsKey;
1367}
1368
1369/// NSStringEncodingDetection.
1370impl NSString {
1371    extern_methods!(
1372        #[cfg(all(feature = "NSData", feature = "NSDictionary"))]
1373        /// # Safety
1374        ///
1375        /// - `opts` generic should be of the correct type.
1376        /// - `used_lossy_conversion` must be a valid pointer or null.
1377        #[unsafe(method(stringEncodingForData:encodingOptions:convertedString:usedLossyConversion:))]
1378        #[unsafe(method_family = none)]
1379        pub unsafe fn stringEncodingForData_encodingOptions_convertedString_usedLossyConversion(
1380            data: &NSData,
1381            opts: Option<&NSDictionary<NSStringEncodingDetectionOptionsKey, AnyObject>>,
1382            string: Option<&mut Option<Retained<NSString>>>,
1383            used_lossy_conversion: *mut Bool,
1384        ) -> NSStringEncoding;
1385    );
1386}
1387
1388/// NSItemProvider.
1389impl NSString {
1390    extern_methods!();
1391}
1392
1393#[cfg(feature = "NSItemProvider")]
1394extern_conformance!(
1395    unsafe impl NSItemProviderReading for NSString {}
1396);
1397
1398#[cfg(feature = "NSItemProvider")]
1399extern_conformance!(
1400    unsafe impl NSItemProviderWriting for NSString {}
1401);
1402
1403extern_class!(
1404    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc)
1405    #[unsafe(super(NSString, NSObject))]
1406    #[derive(Debug, PartialEq, Eq, Hash)]
1407    pub struct NSMutableString;
1408);
1409
1410#[cfg(feature = "objc2-core-foundation")]
1411impl AsRef<NSMutableString> for CFMutableString {
1412    #[inline]
1413    fn as_ref(&self) -> &NSMutableString {
1414        unsafe { &*((self as *const Self).cast()) }
1415    }
1416}
1417
1418#[cfg(feature = "objc2-core-foundation")]
1419impl AsRef<CFMutableString> for NSMutableString {
1420    #[inline]
1421    fn as_ref(&self) -> &CFMutableString {
1422        unsafe { &*((self as *const Self).cast()) }
1423    }
1424}
1425
1426#[cfg(feature = "NSObject")]
1427extern_conformance!(
1428    unsafe impl NSCoding for NSMutableString {}
1429);
1430
1431#[cfg(feature = "NSObject")]
1432extern_conformance!(
1433    unsafe impl NSCopying for NSMutableString {}
1434);
1435
1436#[cfg(feature = "NSObject")]
1437unsafe impl CopyingHelper for NSMutableString {
1438    type Result = NSString;
1439}
1440
1441#[cfg(feature = "NSObject")]
1442extern_conformance!(
1443    unsafe impl NSMutableCopying for NSMutableString {}
1444);
1445
1446#[cfg(feature = "NSObject")]
1447unsafe impl MutableCopyingHelper for NSMutableString {
1448    type Result = Self;
1449}
1450
1451extern_conformance!(
1452    unsafe impl NSObjectProtocol for NSMutableString {}
1453);
1454
1455#[cfg(feature = "NSObject")]
1456extern_conformance!(
1457    unsafe impl NSSecureCoding for NSMutableString {}
1458);
1459
1460impl NSMutableString {
1461    extern_methods!(
1462        #[cfg(feature = "NSRange")]
1463        #[unsafe(method(replaceCharactersInRange:withString:))]
1464        #[unsafe(method_family = none)]
1465        pub fn replaceCharactersInRange_withString(&self, range: NSRange, a_string: &NSString);
1466    );
1467}
1468
1469/// Methods declared on superclass `NSString`.
1470impl NSMutableString {
1471    extern_methods!(
1472        #[unsafe(method(init))]
1473        #[unsafe(method_family = init)]
1474        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1475
1476        #[cfg(feature = "NSCoder")]
1477        /// # Safety
1478        ///
1479        /// `coder` possibly has further requirements.
1480        #[unsafe(method(initWithCoder:))]
1481        #[unsafe(method_family = init)]
1482        pub unsafe fn initWithCoder(
1483            this: Allocated<Self>,
1484            coder: &NSCoder,
1485        ) -> Option<Retained<Self>>;
1486    );
1487}
1488
1489/// Methods declared on superclass `NSObject`.
1490impl NSMutableString {
1491    extern_methods!(
1492        #[unsafe(method(new))]
1493        #[unsafe(method_family = new)]
1494        pub fn new() -> Retained<Self>;
1495    );
1496}
1497
1498impl DefaultRetained for NSMutableString {
1499    #[inline]
1500    fn default_retained() -> Retained<Self> {
1501        Self::new()
1502    }
1503}
1504
1505/// NSMutableStringExtensionMethods.
1506impl NSMutableString {
1507    extern_methods!(
1508        #[unsafe(method(insertString:atIndex:))]
1509        #[unsafe(method_family = none)]
1510        pub fn insertString_atIndex(&self, a_string: &NSString, loc: NSUInteger);
1511
1512        #[cfg(feature = "NSRange")]
1513        #[unsafe(method(deleteCharactersInRange:))]
1514        #[unsafe(method_family = none)]
1515        pub fn deleteCharactersInRange(&self, range: NSRange);
1516
1517        #[unsafe(method(appendString:))]
1518        #[unsafe(method_family = none)]
1519        pub fn appendString(&self, a_string: &NSString);
1520
1521        #[unsafe(method(setString:))]
1522        #[unsafe(method_family = none)]
1523        pub fn setString(&self, a_string: &NSString);
1524
1525        #[cfg(feature = "NSRange")]
1526        #[unsafe(method(replaceOccurrencesOfString:withString:options:range:))]
1527        #[unsafe(method_family = none)]
1528        pub fn replaceOccurrencesOfString_withString_options_range(
1529            &self,
1530            target: &NSString,
1531            replacement: &NSString,
1532            options: NSStringCompareOptions,
1533            search_range: NSRange,
1534        ) -> NSUInteger;
1535
1536        #[cfg(feature = "NSRange")]
1537        /// # Safety
1538        ///
1539        /// `resulting_range` must be a valid pointer or null.
1540        #[unsafe(method(applyTransform:reverse:range:updatedRange:))]
1541        #[unsafe(method_family = none)]
1542        pub unsafe fn applyTransform_reverse_range_updatedRange(
1543            &self,
1544            transform: &NSStringTransform,
1545            reverse: bool,
1546            range: NSRange,
1547            resulting_range: NSRangePointer,
1548        ) -> bool;
1549
1550        #[unsafe(method(initWithCapacity:))]
1551        #[unsafe(method_family = init)]
1552        pub fn initWithCapacity(
1553            this: Allocated<Self>,
1554            capacity: NSUInteger,
1555        ) -> Retained<NSMutableString>;
1556
1557        #[unsafe(method(stringWithCapacity:))]
1558        #[unsafe(method_family = none)]
1559        pub fn stringWithCapacity(capacity: NSUInteger) -> Retained<NSMutableString>;
1560    );
1561}
1562
1563extern "C" {
1564    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscharacterconversionexception?language=objc)
1565    #[cfg(feature = "NSObjCRuntime")]
1566    pub static NSCharacterConversionException: &'static NSExceptionName;
1567}
1568
1569extern "C" {
1570    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsparseerrorexception?language=objc)
1571    #[cfg(feature = "NSObjCRuntime")]
1572    pub static NSParseErrorException: &'static NSExceptionName;
1573}
1574
1575/// NSExtendedStringPropertyListParsing.
1576impl NSString {
1577    extern_methods!(
1578        #[unsafe(method(propertyList))]
1579        #[unsafe(method_family = none)]
1580        pub fn propertyList(&self) -> Retained<AnyObject>;
1581
1582        #[cfg(feature = "NSDictionary")]
1583        #[unsafe(method(propertyListFromStringsFileFormat))]
1584        #[unsafe(method_family = none)]
1585        pub fn propertyListFromStringsFileFormat(&self) -> Option<Retained<NSDictionary>>;
1586    );
1587}
1588
1589/// NSStringDeprecated.
1590impl NSString {
1591    extern_methods!(
1592        #[deprecated = "Use -cStringUsingEncoding: instead"]
1593        #[unsafe(method(cString))]
1594        #[unsafe(method_family = none)]
1595        pub fn cString(&self) -> *const c_char;
1596
1597        #[deprecated = "Use -cStringUsingEncoding: instead"]
1598        #[unsafe(method(lossyCString))]
1599        #[unsafe(method_family = none)]
1600        pub fn lossyCString(&self) -> *const c_char;
1601
1602        #[deprecated = "Use -lengthOfBytesUsingEncoding: instead"]
1603        #[unsafe(method(cStringLength))]
1604        #[unsafe(method_family = none)]
1605        pub fn cStringLength(&self) -> NSUInteger;
1606
1607        /// # Safety
1608        ///
1609        /// `bytes` must be a valid pointer.
1610        #[deprecated = "Use -getCString:maxLength:encoding: instead"]
1611        #[unsafe(method(getCString:))]
1612        #[unsafe(method_family = none)]
1613        pub unsafe fn getCString(&self, bytes: NonNull<c_char>);
1614
1615        /// # Safety
1616        ///
1617        /// `bytes` must be a valid pointer.
1618        #[deprecated = "Use -getCString:maxLength:encoding: instead"]
1619        #[unsafe(method(getCString:maxLength:))]
1620        #[unsafe(method_family = none)]
1621        pub unsafe fn getCString_maxLength(&self, bytes: NonNull<c_char>, max_length: NSUInteger);
1622
1623        #[cfg(feature = "NSRange")]
1624        /// # Safety
1625        ///
1626        /// - `bytes` must be a valid pointer.
1627        /// - `leftover_range` must be a valid pointer or null.
1628        #[deprecated = "Use -getCString:maxLength:encoding: instead"]
1629        #[unsafe(method(getCString:maxLength:range:remainingRange:))]
1630        #[unsafe(method_family = none)]
1631        pub unsafe fn getCString_maxLength_range_remainingRange(
1632            &self,
1633            bytes: NonNull<c_char>,
1634            max_length: NSUInteger,
1635            a_range: NSRange,
1636            leftover_range: NSRangePointer,
1637        );
1638
1639        #[deprecated = "Use -writeToFile:atomically:encoding:error: instead"]
1640        #[unsafe(method(writeToFile:atomically:))]
1641        #[unsafe(method_family = none)]
1642        pub fn writeToFile_atomically(&self, path: &NSString, use_auxiliary_file: bool) -> bool;
1643
1644        #[cfg(feature = "NSURL")]
1645        #[deprecated = "Use -writeToURL:atomically:encoding:error: instead"]
1646        #[unsafe(method(writeToURL:atomically:))]
1647        #[unsafe(method_family = none)]
1648        pub fn writeToURL_atomically(&self, url: &NSURL, atomically: bool) -> bool;
1649
1650        #[deprecated = "Use -initWithContentsOfFile:encoding:error: instead"]
1651        #[unsafe(method(initWithContentsOfFile:))]
1652        #[unsafe(method_family = init)]
1653        pub fn initWithContentsOfFile(
1654            this: Allocated<Self>,
1655            path: &NSString,
1656        ) -> Option<Retained<Self>>;
1657
1658        #[cfg(feature = "NSURL")]
1659        #[deprecated = "Use -initWithContentsOfURL:encoding:error: instead"]
1660        #[unsafe(method(initWithContentsOfURL:))]
1661        #[unsafe(method_family = init)]
1662        pub fn initWithContentsOfURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;
1663
1664        #[deprecated = "Use +stringWithContentsOfFile:encoding:error: instead"]
1665        #[unsafe(method(stringWithContentsOfFile:))]
1666        #[unsafe(method_family = none)]
1667        pub fn stringWithContentsOfFile(path: &NSString) -> Option<Retained<AnyObject>>;
1668
1669        #[cfg(feature = "NSURL")]
1670        #[deprecated = "Use +stringWithContentsOfURL:encoding:error: instead"]
1671        #[unsafe(method(stringWithContentsOfURL:))]
1672        #[unsafe(method_family = none)]
1673        pub fn stringWithContentsOfURL(url: &NSURL) -> Option<Retained<AnyObject>>;
1674
1675        /// # Safety
1676        ///
1677        /// `bytes` must be a valid pointer.
1678        #[deprecated = "Use -initWithCString:encoding: instead"]
1679        #[unsafe(method(initWithCStringNoCopy:length:freeWhenDone:))]
1680        #[unsafe(method_family = init)]
1681        pub unsafe fn initWithCStringNoCopy_length_freeWhenDone(
1682            this: Allocated<Self>,
1683            bytes: NonNull<c_char>,
1684            length: NSUInteger,
1685            free_buffer: bool,
1686        ) -> Option<Retained<Self>>;
1687
1688        /// # Safety
1689        ///
1690        /// `bytes` must be a valid pointer.
1691        #[deprecated = "Use -initWithCString:encoding: instead"]
1692        #[unsafe(method(initWithCString:length:))]
1693        #[unsafe(method_family = init)]
1694        pub unsafe fn initWithCString_length(
1695            this: Allocated<Self>,
1696            bytes: NonNull<c_char>,
1697            length: NSUInteger,
1698        ) -> Option<Retained<Self>>;
1699
1700        /// # Safety
1701        ///
1702        /// `bytes` must be a valid pointer.
1703        #[deprecated = "Use -initWithCString:encoding: instead"]
1704        #[unsafe(method(initWithCString:))]
1705        #[unsafe(method_family = init)]
1706        pub unsafe fn initWithCString(
1707            this: Allocated<Self>,
1708            bytes: NonNull<c_char>,
1709        ) -> Option<Retained<Self>>;
1710
1711        /// # Safety
1712        ///
1713        /// `bytes` must be a valid pointer.
1714        #[deprecated = "Use +stringWithCString:encoding:"]
1715        #[unsafe(method(stringWithCString:length:))]
1716        #[unsafe(method_family = none)]
1717        pub unsafe fn stringWithCString_length(
1718            bytes: NonNull<c_char>,
1719            length: NSUInteger,
1720        ) -> Option<Retained<AnyObject>>;
1721
1722        /// # Safety
1723        ///
1724        /// `bytes` must be a valid pointer.
1725        #[deprecated = "Use +stringWithCString:encoding: instead"]
1726        #[unsafe(method(stringWithCString:))]
1727        #[unsafe(method_family = none)]
1728        pub unsafe fn stringWithCString(bytes: NonNull<c_char>) -> Option<Retained<AnyObject>>;
1729
1730        /// # Safety
1731        ///
1732        /// `buffer` must be a valid pointer.
1733        #[unsafe(method(getCharacters:))]
1734        #[unsafe(method_family = none)]
1735        pub unsafe fn getCharacters(&self, buffer: NonNull<unichar>);
1736    );
1737}
1738
1739/// Methods declared on superclass `NSString`.
1740///
1741/// NSStringDeprecated.
1742impl NSMutableString {
1743    extern_methods!(
1744        #[deprecated = "Use -initWithContentsOfFile:encoding:error: instead"]
1745        #[unsafe(method(initWithContentsOfFile:))]
1746        #[unsafe(method_family = init)]
1747        pub fn initWithContentsOfFile(
1748            this: Allocated<Self>,
1749            path: &NSString,
1750        ) -> Option<Retained<Self>>;
1751
1752        #[cfg(feature = "NSURL")]
1753        #[deprecated = "Use -initWithContentsOfURL:encoding:error: instead"]
1754        #[unsafe(method(initWithContentsOfURL:))]
1755        #[unsafe(method_family = init)]
1756        pub fn initWithContentsOfURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;
1757
1758        /// # Safety
1759        ///
1760        /// `bytes` must be a valid pointer.
1761        #[deprecated = "Use -initWithCString:encoding: instead"]
1762        #[unsafe(method(initWithCStringNoCopy:length:freeWhenDone:))]
1763        #[unsafe(method_family = init)]
1764        pub unsafe fn initWithCStringNoCopy_length_freeWhenDone(
1765            this: Allocated<Self>,
1766            bytes: NonNull<c_char>,
1767            length: NSUInteger,
1768            free_buffer: bool,
1769        ) -> Option<Retained<Self>>;
1770
1771        /// # Safety
1772        ///
1773        /// `bytes` must be a valid pointer.
1774        #[deprecated = "Use -initWithCString:encoding: instead"]
1775        #[unsafe(method(initWithCString:length:))]
1776        #[unsafe(method_family = init)]
1777        pub unsafe fn initWithCString_length(
1778            this: Allocated<Self>,
1779            bytes: NonNull<c_char>,
1780            length: NSUInteger,
1781        ) -> Option<Retained<Self>>;
1782
1783        /// # Safety
1784        ///
1785        /// `bytes` must be a valid pointer.
1786        #[deprecated = "Use -initWithCString:encoding: instead"]
1787        #[unsafe(method(initWithCString:))]
1788        #[unsafe(method_family = init)]
1789        pub unsafe fn initWithCString(
1790            this: Allocated<Self>,
1791            bytes: NonNull<c_char>,
1792        ) -> Option<Retained<Self>>;
1793    );
1794}
1795
1796extern_class!(
1797    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssimplecstring?language=objc)
1798    #[unsafe(super(NSString, NSObject))]
1799    #[derive(Debug, PartialEq, Eq, Hash)]
1800    pub struct NSSimpleCString;
1801);
1802
1803#[cfg(feature = "NSObject")]
1804extern_conformance!(
1805    unsafe impl NSCoding for NSSimpleCString {}
1806);
1807
1808extern_conformance!(
1809    unsafe impl NSObjectProtocol for NSSimpleCString {}
1810);
1811
1812#[cfg(feature = "NSObject")]
1813extern_conformance!(
1814    unsafe impl NSSecureCoding for NSSimpleCString {}
1815);
1816
1817impl NSSimpleCString {
1818    extern_methods!();
1819}
1820
1821/// Methods declared on superclass `NSString`.
1822impl NSSimpleCString {
1823    extern_methods!(
1824        #[unsafe(method(init))]
1825        #[unsafe(method_family = init)]
1826        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1827
1828        #[cfg(feature = "NSCoder")]
1829        /// # Safety
1830        ///
1831        /// `coder` possibly has further requirements.
1832        #[unsafe(method(initWithCoder:))]
1833        #[unsafe(method_family = init)]
1834        pub unsafe fn initWithCoder(
1835            this: Allocated<Self>,
1836            coder: &NSCoder,
1837        ) -> Option<Retained<Self>>;
1838    );
1839}
1840
1841/// Methods declared on superclass `NSObject`.
1842impl NSSimpleCString {
1843    extern_methods!(
1844        #[unsafe(method(new))]
1845        #[unsafe(method_family = new)]
1846        pub fn new() -> Retained<Self>;
1847    );
1848}
1849
1850impl DefaultRetained for NSSimpleCString {
1851    #[inline]
1852    fn default_retained() -> Retained<Self> {
1853        Self::new()
1854    }
1855}
1856
1857extern_class!(
1858    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsconstantstring?language=objc)
1859    #[unsafe(super(NSSimpleCString, NSString, NSObject))]
1860    #[derive(Debug, PartialEq, Eq, Hash)]
1861    pub struct NSConstantString;
1862);
1863
1864#[cfg(feature = "NSObject")]
1865extern_conformance!(
1866    unsafe impl NSCoding for NSConstantString {}
1867);
1868
1869extern_conformance!(
1870    unsafe impl NSObjectProtocol for NSConstantString {}
1871);
1872
1873#[cfg(feature = "NSObject")]
1874extern_conformance!(
1875    unsafe impl NSSecureCoding for NSConstantString {}
1876);
1877
1878impl NSConstantString {
1879    extern_methods!();
1880}
1881
1882/// Methods declared on superclass `NSString`.
1883impl NSConstantString {
1884    extern_methods!(
1885        #[unsafe(method(init))]
1886        #[unsafe(method_family = init)]
1887        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1888
1889        #[cfg(feature = "NSCoder")]
1890        /// # Safety
1891        ///
1892        /// `coder` possibly has further requirements.
1893        #[unsafe(method(initWithCoder:))]
1894        #[unsafe(method_family = init)]
1895        pub unsafe fn initWithCoder(
1896            this: Allocated<Self>,
1897            coder: &NSCoder,
1898        ) -> Option<Retained<Self>>;
1899    );
1900}
1901
1902/// Methods declared on superclass `NSObject`.
1903impl NSConstantString {
1904    extern_methods!(
1905        #[unsafe(method(new))]
1906        #[unsafe(method_family = new)]
1907        pub fn new() -> Retained<Self>;
1908    );
1909}
1910
1911impl DefaultRetained for NSConstantString {
1912    #[inline]
1913    fn default_retained() -> Retained<Self> {
1914        Self::new()
1915    }
1916}