Struct NSString

Source
#[repr(C)]
pub struct NSString { pub ptr: ShareId<Object>, /* private fields */ }
Expand description

This is a mapping to the Objective-C NSString class.

Fields§

§ptr: ShareId<Object>

The raw pointer to the Objective-C object.

Implementations§

Source§

impl NSString

Source

pub fn bytes(&self) -> *const c_char

Returns the UTF8 bytes for this NSString.

Source

pub fn as_str(&self) -> Result<&str, Utf8Error>

Convert this NSString into a &str.

Source§

impl NSString

Source

pub fn string() -> Self

Returns an empty string.

Source

pub fn init(&mut self) -> Self
where Self: Sized + FromId,

Returns an initialized NSString object that contains no characters.

Source

pub fn init_with_bytes_length_encoding( &mut self, bytes: *const c_void, len: UInt, encoding: Encoding, ) -> Self
where Self: Sized + FromId,

Returns an initialized NSString object containing a given number of bytes from a given buffer of bytes interpreted in a given encoding.

§Arguments
  • bytes - A buffer of bytes interpreted in the encoding specified by encoding.

  • len - The number of bytes to use from bytes.

  • encoding - The character encoding applied to bytes. For possible values, see NSStringEncoding.

§Returns

An initialized NSString object containing length bytes from bytes interpreted using the encoding encoding. The returned object may be different from the original receiver.

Source

pub fn init_with_bytes_no_copy_length_encoding_free_when_done( &mut self, bytes: *mut c_void, len: UInt, encoding: Encoding, free_buffer: bool, ) -> Self
where Self: Sized + FromId,

Returns an initialized NSString object that contains a given number of bytes from a given buffer of bytes interpreted in a given encoding, and optionally frees the buffer.

§Arguments
  • bytes - A buffer of bytes interpreted in the encoding specified by encoding.
  • len - The number of bytes to use from bytes.
  • encoding - The character encoding applied to bytes. For possible values, see NSStringEncoding.
  • free_buffer - If YES, bytes is freed after use.
§Returns

An initialized NSString object containing length bytes from bytes interpreted using the encoding encoding. The returned object may be different from the original receiver.

Source

pub fn init_with_characters_length( &mut self, characters: *const unichar, len: UInt, ) -> Self
where Self: Sized + FromId,

Returns an initialized NSString object that contains a given number of characters from a given C array of UTF-16 code units.

§Arguments
  • characters - A C array of UTF-16 code units; the value must not be NULL.
  • length - A C array of UTF-16 code units; the value must not be NULL.
§Returns

An initialized NSString object containing length characters from characters.

Source

pub fn init_with_characters_no_copy_length_free_when_done( &mut self, characters: unichar, length: UInt, free_buffer: bool, ) -> Self
where Self: Sized + FromId,

Returns an initialized NSString object that contains a given number of characters from a given C array of UTF-16 code units.

§Arguments
  • characters - A C array of UTF-16 code units; the value must not be NULL.
  • length - A C array of UTF-16 code units; the value must not be NULL.
  • free_buffer - If YES, characters is freed after use.
§Returns

An initialized NSString object containing length characters from characters.

Source

pub fn init_with_string<S>(&mut self, s: S) -> Self
where Self: Sized + FromId, S: INSString,

Returns an NSString object initialized by copying the characters from another given string.

§Arguments
  • s - The string from which to copy characters. This value must not be nil.
§Returns

An NSString object initialized by copying the characters from s.

Source

pub fn init_with_cstring_encoding( &mut self, c_str: *const c_char, encoding: Encoding, ) -> Self
where Self: Sized + FromId,

Returns an NSString object initialized using the characters in a given C array, interpreted according to a given encoding.

§Arguments
  • c_str - A C array of bytes.
  • encoding - The encoding to use to interpret c_str. For possible values, see NSStringEncoding.
§Returns

An NSString object initialized using the characters in c_str, interpreted according to encoding.

Source

pub fn init_with_utf8_string(&mut self, c_str: *const c_char) -> Self
where Self: Sized + FromId,

Returns an NSString object initialized using the characters in a given C array, interpreted according to a UTF8 string.

§Arguments
  • c_str - A C array of bytes.
§Returns

An NSString object initialized using the characters in c_str, interpreted as a UTF8 string.

Source

pub fn init_with_data_encoding( &mut self, data: NSData, encoding: Encoding, ) -> Self
where Self: Sized + FromId,

Returns an NSString object initialized by converting given data into UTF-16 code units using a given encoding.

§Arguments
  • data - The data to convert into UTF-16 code units.
  • encoding - The encoding to use to interpret data. For possible values, see NSStringEncoding.
§Returns

An NSString object initialized by converting data into UTF-16 code units using encoding.

Source

pub fn localized_user_notification_string_for_key_arguments<T>( key: NSString, arguments: NSArray<T>, ) -> NSString
where T: PNSObject,

Returns a localized string intended for display in a notification alert.

§Arguments
  • key - The key to use when looking up the string in the app’s Localizable.strings file.
  • arguments - An array of values to substitute for escaped characters in the string.
Source

pub fn string_with_characters_length( characters: *const unichar, length: UInt, ) -> Self

Returns a string containing a given number of characters taken from a given C array of UTF-16 code units.

§Arguments
  • characters - A C array of UTF-16 code units; the value must not be NULL.
  • length - A C array of UTF-16 code units; the value must not be NULL.
§Returns

An NSString object containing length characters from characters.

Source

pub fn string_with_string(s: NSString) -> Self

Returns a string created by copying the characters from another given string.

§Arguments
  • s - The string from which to copy characters. This value must not be nil.
§Returns

An NSString object initialized by copying the characters from s.

Source

pub fn string_with_cstring_encoding( c_str: *const c_char, encoding: Encoding, ) -> Self

Returns a string containing the bytes in a given C array, interpreted according to a given encoding.

§Arguments
  • c_str - A C array of bytes.
  • encoding - The encoding to use to interpret c_str. For possible values, see NSStringEncoding.
§Returns

An NSString object containing the bytes in c_str, interpreted according to encoding.

Source

pub fn string_with_utf8_string(c_str: *const c_char) -> Self

Returns a string created by copying the data from a given C array of UTF8-encoded bytes.

§Arguments
  • c_str - A C array of bytes.
§Returns

An NSString object containing the bytes in c_str, interpreted as a UTF8 string.

Source

pub fn string_with_contents_of_file_encoding( path: &NSString, enc: Encoding, ) -> Result<Self, NSError>

Returns a string created by reading data from the file at a given path interpreted using a given encoding.

Source

pub fn init_with_contents_of_file_encoding( &mut self, path: &NSString, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns an NSString object initialized by reading data from the file at a given path using a given encoding.

Source

pub fn string_with_contents_of_file_used_encoding( path: &NSString, enc: Encoding, ) -> Result<Self, NSError>

Returns an NSString object initialized by reading data from the file at a given path using a given encoding.

Source

pub fn init_with_contents_of_file_used_encoding( &mut self, path: &NSString, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns a string created by reading data from the file at a given path and returns by reference the encoding used to interpret the file.

Source

pub fn string_with_contents_of_url_encoding( path: &NSURL, enc: Encoding, ) -> Result<Self, NSError>

Returns a string created by reading data from a given URL interpreted using a given encoding.

Source

pub fn init_with_contents_of_url_encoding( &mut self, path: &NSURL, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns an NSString object initialized by reading data from a given URL interpreted using a given encoding.

Source

pub fn string_with_contents_of_url_used_encoding( path: &NSURL, enc: Encoding, ) -> Result<Self, NSError>

Returns a string created by reading data from a given URL and returns by reference the encoding used to interpret the data.

Source

pub fn init_with_contents_of_url_used_encoding( &mut self, path: &NSURL, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns an NSString object initialized by reading data from a given URL and returns by reference the encoding used to interpret the data.

Source

pub fn length(&self) -> UInt

The number of Unicode characters in this string.

Source

pub fn length_of_bytes_using_encoding(&self, enc: Encoding) -> UInt

Returns the number of bytes required to store the receiver in a given encoding.

§Arguments
  • enc - The encoding for which to determine the receiver’s length.
§Returns

The number of bytes required to store the receiver in the encoding enc in a non-external representation. The length does not include space for a terminating NULL character. Returns 0 if the specified encoding cannot be used to convert the receiver or if the amount of memory required for storing the results of the encoding conversion would exceed NSIntegerMax.

Source

pub fn maximum_length_of_bytes_using_encoding(&self, enc: Encoding) -> Int

Returns the maximum number of bytes needed to store the receiver in a given encoding.

§Arguments
  • enc - The encoding for which to determine the receiver’s length.
§Returns

The maximum number of bytes needed to store the receiver in encoding in a non-external representation. The length does not include space for a terminating NULL character. Returns 0 if the amount of memory required for storing the results of the encoding conversion would exceed NSIntegerMax.

Source

pub fn character_at_index(&self, index: UInt) -> char

Returns the character at a given UTF-16 code unit index.

§Arguments
  • index - The character at the array position given by index.
§Returns

The character at the array position given by index.

Source

pub fn get_characters_range(&self, buffer: *mut unichar, range: NSRange)

Copies characters from a given range in the receiver into a given buffer.

§Arguments
  • buffer - Upon return, contains the characters from the receiver. buffer must be large enough to contain the characters in the range aRange (aRange.length*sizeof(unichar)).
  • range - The range of characters to copy.
Source

pub fn get_bytes_max_length_used_length_encoding_options_range_remaining_range( &self, buffer: *mut c_void, max_length: Int, used_length: *mut Int, encoding: Encoding, options: NSStringEncodingConversionOptions, range: NSRange, remaining_range: NSRange, ) -> bool

Gets a given range of characters as bytes in a specified encoding.

§Arguments
  • buffer - Upon return, contains the bytes from the receiver. buffer must be large enough to contain the bytes in the range aRange (aRange.length*sizeof(char)).
  • `maxLength - The maximum number of bytes to get.
  • usedLength - Upon return, contains the actual number of bytes retrieved.
  • encoding - The encoding to use to interpret the bytes. For possible values, see NSStringEncoding.
  • options - The options to use for converting the receiver into the specified encoding. For possible values, see NSStringEncodingConversionOptions.
  • range - The range of characters to get.
  • remainingRange - Upon return, contains a range containing the remaining characters.
Source

pub fn c_string_using_encoding(&self, encoding: Encoding) -> *const c_char

Returns a representation of the string as a C string using a given encoding.

§Arguments
  • encoding - The encoding to use to interpret the receiver. For possible values, see NSStringEncoding.
§Returns

A pointer to a C string containing the receiver. The pointer is owned by the string, and must not be freed by the caller.

Source

pub fn get_cstring_max_length_encoding( &self, buffer: *mut c_char, max_length: UInt, encoding: Encoding, ) -> bool

Returns a representation of the string as a C string.

§Arguments
  • buffer - Upon return, contains the characters from the receiver. buffer must be large enough to contain the characters in the receiver.
  • maxLength - The maximum number of bytes to write into buffer.
  • encoding - The encoding to use to interpret the receiver. For possible values, see NSStringEncoding.
§Returns

true if the operation was successful, otherwise false. Returns false if conversion is not possible due to encoding errors or if buffer is too small.

Source

pub fn utf8_string(&self) -> *const c_char

A null-terminated UTF8 representation of the string.

Source

pub fn case_insensitive_compare<S>(&self, string: S) -> NSComparisonResult
where S: INSString,

Returns the result of invoking compare:options: with NSCaseInsensitiveSearch as the only option.

§Arguments
  • string - The string to compare.
§Returns

Returns an ComparisonResult value that indicates the lexical ordering. OrderedAscending the receiver precedes string in lexical ordering, OrderedSame the receiver and string are equivalent in lexical value, and OrderedDescending if the receiver follows string.

Source

pub fn localized_case_insensitive_compare<S>( &self, string: S, ) -> NSComparisonResult
where S: INSString,

Compares the string with a given string using a case-insensitive, localized, comparison.

§Arguments
  • string - The string to compare.
§Returns

Returns an ComparisonResult value that indicates the lexical ordering. OrderedAscending the receiver precedes string in lexical ordering, OrderedSame the receiver and string are equivalent in lexical value, and OrderedDescending if the receiver follows string

Source

pub fn compare<S>(&self, string: S) -> NSComparisonResult
where S: INSString,

Returns the result of invoking compare:options:range: with no options and the receiver’s full extent as the range.

§Arguments
  • string - The string with which to compare the receiver.
§Safety

This value must not be nil. If this value is nil, the behavior is undefined and may change in future versions of macOS.

§Returns

Returns an ComparisonResult value that indicates the lexical ordering. OrderedAscending the receiver precedes string in lexical ordering, OrderedSame the receiver and string are equivalent in lexical value, and OrderedDescending if the receiver follows string

Source

pub fn localized_compare<S>(&self, string: S) -> NSComparisonResult
where S: INSString,

Returns the result of invoking compare:options:range: with no options and the receiver’s full extent as the range.

§Arguments
  • string - The string with which to compare the receiver.

Returns an ComparisonResult value that indicates the lexical ordering. OrderedAscending the receiver precedes string in lexical ordering, OrderedSame the receiver and string are equivalent in lexical value, and OrderedDescending if the receiver follows string

Source

pub fn compare_options<S>( &self, string: S, mask: NSStringCompareOptions, ) -> NSComparisonResult
where S: INSString,

Compares the string with the specified string using the given options.

§Arguments
  • string - The string to compare.
  • mask - The mask to use when comparing the receiver and string.
§Returns

Returns an ComparisonResult value that indicates the lexical ordering.

Source

pub fn compare_options_range<S>( &self, string: S, mask: NSStringCompareOptions, range: NSRange, ) -> NSComparisonResult
where S: INSString,

Compares the string with the specified string using the given options.

§Arguments
  • string - The string to compare.
  • mask - The mask to use when comparing the receiver and string.
  • range - The range of the receiver to compare.
Source

pub fn compare_options_range_locale<S>( &self, string: S, mask: NSStringCompareOptions, range: NSRange, locale: NSLocale, ) -> NSComparisonResult
where S: INSString,

Compares the string using the specified options and returns the lexical ordering for the range.

§Arguments
  • string - The string to compare.
  • mask - The mask to use when comparing the receiver and string.
  • range - The range to compare.
  • locale - The locale to use when comparing the receiver and string.
§Returns

Returns an ComparisonResult value that indicates the lexical ordering.

Source

pub fn localized_standard_compare<S>(&self, string: S) -> NSComparisonResult
where S: INSString,

Compares strings as sorted by the Finder.

§Arguments
  • string - The string to compare with the receiver.
§Returns

The result of the comparison.

Source

pub fn has_prefix<S>(&self, prefix: S) -> bool
where S: INSString,

Returns a Boolean value that indicates whether a given string matches the beginning characters of the receiver.

§Arguments
  • prefix - The prefix to search for.
§Returns

Returns true if the string begins with the prefix, otherwise false.

Source

pub fn has_suffix<S>(&self, suffix: S) -> bool
where S: INSString,

Returns a Boolean value that indicates whether a given string matches the ending characters of the receiver.

§Arguments
  • suffix - The suffix to search for.
§Returns

Returns true if the string ends with the suffix, otherwise false.

Source

pub fn is_equal_to_string<S>(&self, string: S) -> bool
where S: INSString,

Returns a Boolean value that indicates whether a given string is equal to the receiver using a literal Unicode-based comparison.

§Arguments
  • string - The string to compare with the receiver.
§Returns

Returns true if the string is equal to the receiver, otherwise false.

Source

pub fn string_by_appending_string<S>(&self, string: S) -> NSString
where S: INSString,

Returns a new string made by appending a given string to the receiver.

§Arguments
  • string - The string to append to the receiver. This value must not be nil.
Source

pub fn string_by_padding_to_length_with_string_starting_at_index<S>( &self, new_length: UInt, pad_string: S, starting_at: UInt, ) -> NSString
where S: INSString,

Returns a new string formed from the receiver by either removing characters from the end, or by appending as many occurrences as necessary of a given pad string.

§Arguments
  • new_length - The number of characters to be contained in the new string.
  • pad - The string to use for padding.
  • starting_at - The index in pad_string from which to start padding.
§Returns

A new string formed from the receiver by either removing characters from the end, or by appending as many occurrences of pad_string as necessary.

Source

pub fn lowercase_string(&self) -> NSString

A lowercase representation of the string.

Source

pub fn localized_lowercase_string(&self) -> NSString

Returns a version of the string with all letters converted to lowercase, taking into account the current locale.

Source

pub fn lowercase_string_with_locale(&self, locale: NSLocale) -> NSString

Returns a version of the string with all letters converted to lowercase, taking into account the specified locale.

§Arguments
  • locale - The locale to use when converting the letters to lowercase.
§Returns

A new string with all letters converted to lowercase.

Source

pub fn uppercase_string(&self) -> NSString

An uppercase representation of the string.

Source

pub fn localized_uppercase_string(&self) -> NSString

Returns a version of the string with all letters converted to uppercase, taking into account the current locale.

Source

pub fn uppercase_string_with_locale(&self, locale: NSLocale) -> NSString

Returns a version of the string with all letters converted to uppercase, taking into account the specified locale.

§Arguments
  • locale - The locale to use when converting the letters to uppercase.
§Returns

A new string with all letters converted to uppercase.

Source

pub fn capitalized_string(&self) -> NSString

A capitalized representation of the string.

Source

pub fn localized_capitalized_string(&self) -> NSString

Returns a capitalized representation of the receiver using the current locale.

Source

pub fn capitalized_string_with_locale(&self, locale: NSLocale) -> NSString

Returns a capitalized representation of the receiver using the specified locale.

Source

pub fn components_separated_by_string<S>( &self, separator: S, ) -> NSArray<NSString>
where S: INSString,

Returns an array containing substrings from the receiver that have been divided by a given separator.

Source

pub fn components_separated_by_characters_in_set( &self, separator: &NSCharacterSet, ) -> NSArray<NSString>

Returns an array containing substrings from the receiver that have been divided by characters in a given set.

Source

pub fn string_by_trimming_characters_in_set( &self, set: &NSCharacterSet, ) -> NSString

Returns a new string made by removing from both ends of the receiver characters contained in a given character set.

Source

pub fn substring_from_index(&self, from: UInt) -> NSString

Returns a new string containing the characters of the receiver from the one at a given index to the end.

Source

pub fn substring_with_range(&self, range: NSRange) -> NSString

Returns a string object containing the characters of the receiver that lie within a given range.

Source

pub fn substring_to_index(&self, to: UInt) -> NSString

Returns a new string containing the characters of the receiver up to, but not including, the one at a given index.

Source

pub fn decomposed_string_with_canonical_mapping(&self) -> NSString

A string made by normalizing the string’s contents using the Unicode Normalization Form D.

Source

pub fn decomposed_string_with_compatibility_mapping(&self) -> NSString

A string made by normalizing the receiver’s contents using the Unicode Normalization Form KD.

Source

pub fn precomposed_string_with_canonical_mapping(&self) -> NSString

A string made by normalizing the string’s contents using the Unicode Normalization Form C.

Source

pub fn precomposed_string_with_compatibility_mapping(&self) -> NSString

A string made by normalizing the receiver’s contents using the Unicode Normalization Form KC.

Source

pub fn string_by_folding_with_options_locale( &mut self, options: NSStringCompareOptions, locale: &NSLocale, ) -> NSString

Creates a string suitable for comparison by removing the specified character distinctions from a string.

Source

pub fn string_by_applying_transform_reverse( &mut self, transform: NSStringTransform, reverse: bool, ) -> Option<NSString>

Returns a new string made by appending to the receiver a given string.

§Arguments
  • transform - The StringTransform to apply.
  • reverse - If true, the transformation is applied in reverse.
Source

pub fn contains_string<S>(&self, other: S) -> bool
where S: INSString,

Returns a boolean value indicating whether the string contains a given string by performing a case-sensitive, locale-unaware search.

§Arguments
  • string - The string to search for.
§Returns

Returns true if string is contained in the receiver, otherwise false.

Source

pub fn available_string_encodings() -> *const Encoding

Returns a zero-terminated list of the encodings string objects support in the application’s environment.

Source

pub fn default_cstring_encoding() -> Encoding

Returns the C-string encoding assumed for any method accepting a C string as an argument.

Source

pub fn can_be_converted_to_encoding(&self, encoding: Encoding) -> bool

Returns a Boolean value that indicates whether the receiver can be converted to a given encoding without loss of information.

Source

pub fn data_using_encoding(&self, encoding: Encoding) -> NSData

Returns an NSData object containing a representation of the receiver encoded using a given encoding.

Trait Implementations§

Source§

impl Clone for NSString

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NSString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NSString

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for NSString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Encode for NSString

Source§

fn encode() -> Encoding

Returns the Objective-C type encoding for Self.
Source§

impl From<&&str> for NSString

Source§

fn from(s: &&str) -> Self

Creates a new NSString from a &str.

Source§

impl From<&str> for NSString

Source§

fn from(s: &str) -> Self

Creates a new NSString from a &str.

Source§

impl From<(&str, Encoding)> for NSString

Source§

fn from((s, encoding): (&str, Encoding)) -> Self

Creates a new NSString from a &str and an encoding.

Source§

impl From<NSMutableString> for NSString

Source§

fn from(string: NSMutableString) -> Self

Converts to this type from the input type.
Source§

impl From<NSString> for &str

Source§

fn from(string: NSString) -> Self

Converts a NSString to a &str.

Source§

impl From<NSString> for NSMutableString

Source§

fn from(string: NSString) -> Self

Converts to this type from the input type.
Source§

impl From<String> for NSString

Source§

fn from(s: String) -> Self

Creates a new NSString from a String.

Source§

impl From<char> for NSString

Source§

fn from(c: char) -> Self

Creates a new NSString from a char.

Source§

impl FromId for NSString

Source§

unsafe fn from_id(id: id) -> Self

Returns Self representation of the object. Read more
Source§

impl FromIterator<NSString> for NSArray<NSString>

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = NSString>,

Creates a value from an iterator. Read more
Source§

impl INSString for NSString

Source§

fn m_string() -> Self
where Self: Sized + FromId,

Returns an empty string.
Source§

fn m_init(&mut self) -> Self
where Self: Sized + FromId,

Returns an initialized NSString object that contains no characters.
Source§

fn m_init_with_bytes_length_encoding( &mut self, bytes: *const c_void, len: UInt, encoding: Encoding, ) -> Self
where Self: Sized + FromId,

Returns an initialized NSString object containing a given number of bytes from a given buffer of bytes interpreted in a given encoding. Read more
Source§

fn m_init_with_bytes_no_copy_length_encoding_free_when_done( &mut self, bytes: *mut c_void, len: UInt, encoding: Encoding, free_buffer: bool, ) -> Self
where Self: Sized + FromId,

Returns an initialized NSString object that contains a given number of bytes from a given buffer of bytes interpreted in a given encoding, and optionally frees the buffer. Read more
Source§

fn m_init_with_characters_length( &mut self, characters: *const unichar, len: UInt, ) -> Self
where Self: Sized + FromId,

Returns an initialized NSString object that contains a given number of characters from a given C array of UTF-16 code units. Read more
Source§

fn m_init_with_characters_no_copy_length_free_when_done( &mut self, characters: unichar, length: UInt, free_buffer: bool, ) -> Self
where Self: Sized + FromId,

Returns an initialized NSString object that contains a given number of characters from a given C array of UTF-16 code units. Read more
Source§

fn m_init_with_string<S>(&mut self, s: S) -> Self
where Self: Sized + FromId, S: INSString,

Returns an NSString object initialized by copying the characters from another given string. Read more
Source§

fn m_init_with_cstring_encoding( &mut self, c_str: *const c_char, encoding: Encoding, ) -> Self
where Self: Sized + FromId,

Returns an NSString object initialized using the characters in a given C array, interpreted according to a given encoding. Read more
Source§

fn m_init_with_utf8_string(&mut self, c_str: *const c_char) -> Self
where Self: Sized + FromId,

Returns an NSString object initialized using the characters in a given C array, interpreted according to a UTF8 string. Read more
Source§

fn m_init_with_data_encoding( &mut self, data: NSData, encoding: Encoding, ) -> Self
where Self: Sized + FromId,

Returns an NSString object initialized by converting given data into UTF-16 code units using a given encoding. Read more
Source§

fn m_localized_user_notification_string_for_key_arguments<T>( key: NSString, arguments: NSArray<T>, ) -> NSString
where T: PNSObject,

Returns a localized string intended for display in a notification alert. Read more
Source§

fn m_string_with_characters_length( characters: *const unichar, length: UInt, ) -> Self
where Self: Sized + FromId,

Returns a string containing a given number of characters taken from a given C array of UTF-16 code units. Read more
Source§

fn m_string_with_string(s: NSString) -> Self
where Self: Sized + 'static + FromId,

Returns a string created by copying the characters from another given string. Read more
Source§

fn m_string_with_cstring_encoding( c_str: *const c_char, encoding: Encoding, ) -> Self
where Self: Sized + FromId,

Returns a string containing the bytes in a given C array, interpreted according to a given encoding. Read more
Source§

fn m_string_with_utf8_string(c_str: *const c_char) -> Self
where Self: Sized + FromId,

Returns a string created by copying the data from a given C array of UTF8-encoded bytes. Read more
Source§

fn m_string_with_contents_of_file_encoding( path: &NSString, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns a string created by reading data from the file at a given path interpreted using a given encoding.
Source§

fn m_init_with_contents_of_file_encoding( &mut self, path: &NSString, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns an NSString object initialized by reading data from the file at a given path using a given encoding.
Source§

fn m_string_with_contents_of_file_used_encoding( path: &NSString, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns an NSString object initialized by reading data from the file at a given path using a given encoding.
Source§

fn m_init_with_contents_of_file_used_encoding( &mut self, path: &NSString, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns a string created by reading data from the file at a given path and returns by reference the encoding used to interpret the file.
Source§

fn m_string_with_contents_of_url_encoding( path: &NSURL, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns a string created by reading data from a given URL interpreted using a given encoding.
Source§

fn m_init_with_contents_of_url_encoding( &mut self, path: &NSURL, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns an NSString object initialized by reading data from a given URL interpreted using a given encoding.
Source§

fn m_string_with_contents_of_url_used_encoding( path: &NSURL, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns a string created by reading data from a given URL and returns by reference the encoding used to interpret the data.
Source§

fn m_init_with_contents_of_url_used_encoding( &mut self, path: &NSURL, enc: Encoding, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns an NSString object initialized by reading data from a given URL and returns by reference the encoding used to interpret the data.
Source§

fn p_length(&self) -> UInt

The number of Unicode characters in this string.
Source§

fn m_length_of_bytes_using_encoding(&self, enc: Encoding) -> UInt

Returns the number of bytes required to store the receiver in a given encoding. Read more
Source§

fn m_maximum_length_of_bytes_using_encoding(&self, enc: Encoding) -> Int

Returns the maximum number of bytes needed to store the receiver in a given encoding. Read more
Source§

fn m_character_at_index(&self, index: UInt) -> char

Returns the character at a given UTF-16 code unit index. Read more
Source§

fn m_get_characters_range(&self, buffer: *mut unichar, range: NSRange)

Copies characters from a given range in the receiver into a given buffer. Read more
Source§

fn m_get_bytes_max_length_used_length_encoding_options_range_remaining_range( &self, buffer: *mut c_void, max_length: Int, used_length: *mut Int, encoding: Encoding, options: NSStringEncodingConversionOptions, range: NSRange, remaining_range: NSRange, ) -> bool

Gets a given range of characters as bytes in a specified encoding. Read more
Source§

fn m_c_string_using_encoding(&self, encoding: Encoding) -> *const c_char

Returns a representation of the string as a C string using a given encoding. Read more
Source§

fn m_get_cstring_max_length_encoding( &self, buffer: *mut c_char, max_length: UInt, encoding: Encoding, ) -> bool

Returns a representation of the string as a C string. Read more
Source§

fn p_utf8_string(&self) -> *const c_char

A null-terminated UTF8 representation of the string.
Source§

fn m_case_insensitive_compare<S>(&self, string: S) -> NSComparisonResult
where S: INSString,

Returns the result of invoking compare:options: with NSCaseInsensitiveSearch as the only option. Read more
Source§

fn m_localized_case_insensitive_compare<S>( &self, string: S, ) -> NSComparisonResult
where S: INSString,

Compares the string with a given string using a case-insensitive, localized, comparison. Read more
Source§

fn m_compare<S>(&self, string: S) -> NSComparisonResult
where S: INSString,

Returns the result of invoking compare:options:range: with no options and the receiver’s full extent as the range. Read more
Source§

fn m_localized_compare<S>(&self, string: S) -> NSComparisonResult
where S: INSString,

Returns the result of invoking compare:options:range: with no options and the receiver’s full extent as the range. Read more
Source§

fn m_compare_options<S>( &self, string: S, mask: NSStringCompareOptions, ) -> NSComparisonResult
where S: INSString,

Compares the string with the specified string using the given options. Read more
Source§

fn m_compare_options_range<S>( &self, string: S, mask: NSStringCompareOptions, range: NSRange, ) -> NSComparisonResult
where S: INSString,

Compares the string with the specified string using the given options. Read more
Source§

fn m_compare_options_range_locale<S>( &self, string: S, mask: NSStringCompareOptions, range: NSRange, locale: NSLocale, ) -> NSComparisonResult
where S: INSString,

Compares the string using the specified options and returns the lexical ordering for the range. Read more
Source§

fn m_localized_standard_compare<S>(&self, string: S) -> NSComparisonResult
where S: INSString,

Compares strings as sorted by the Finder. Read more
Source§

fn m_has_prefix<S>(&self, prefix: S) -> bool
where S: INSString,

Returns a Boolean value that indicates whether a given string matches the beginning characters of the receiver. Read more
Source§

fn m_has_suffix<S>(&self, suffix: S) -> bool
where S: INSString,

Returns a Boolean value that indicates whether a given string matches the ending characters of the receiver. Read more
Source§

fn m_is_equal_to_string<S>(&self, string: S) -> bool
where S: INSString,

Returns a Boolean value that indicates whether a given string is equal to the receiver using a literal Unicode-based comparison. Read more
Source§

fn m_string_by_appending_string<S>(&self, string: S) -> NSString
where S: INSString,

Returns a new string made by appending a given string to the receiver. Read more
Source§

fn m_string_by_padding_to_length_with_string_starting_at_index<S>( &self, new_length: UInt, pad_string: S, starting_at: UInt, ) -> NSString
where S: INSString,

Returns a new string formed from the receiver by either removing characters from the end, or by appending as many occurrences as necessary of a given pad string. Read more
Source§

fn p_lowercase_string(&self) -> NSString

A lowercase representation of the string.
Source§

fn p_localized_lowercase_string(&self) -> NSString

Returns a version of the string with all letters converted to lowercase, taking into account the current locale.
Source§

fn m_lowercase_string_with_locale(&self, locale: NSLocale) -> NSString

Returns a version of the string with all letters converted to lowercase, taking into account the specified locale. Read more
Source§

fn p_uppercase_string(&self) -> NSString

An uppercase representation of the string.
Source§

fn p_localized_uppercase_string(&self) -> NSString

Returns a version of the string with all letters converted to uppercase, taking into account the current locale.
Source§

fn m_uppercase_string_with_locale(&self, locale: NSLocale) -> NSString

Returns a version of the string with all letters converted to uppercase, taking into account the specified locale. Read more
Source§

fn p_capitalized_string(&self) -> NSString

A capitalized representation of the string.
Source§

fn p_localized_capitalized_string(&self) -> NSString

Returns a capitalized representation of the receiver using the current locale.
Source§

fn m_capitalized_string_with_locale(&self, locale: NSLocale) -> NSString

Returns a capitalized representation of the receiver using the specified locale.
Source§

fn m_components_separated_by_string<S>(&self, separator: S) -> NSArray<NSString>
where S: INSString,

Returns an array containing substrings from the receiver that have been divided by a given separator.
Source§

fn m_components_separated_by_characters_in_set( &self, separator: &NSCharacterSet, ) -> NSArray<NSString>

Returns an array containing substrings from the receiver that have been divided by characters in a given set.
Source§

fn m_string_by_trimming_characters_in_set( &self, set: &NSCharacterSet, ) -> NSString

Returns a new string made by removing from both ends of the receiver characters contained in a given character set.
Source§

fn m_substring_from_index(&self, from: UInt) -> NSString

Returns a new string containing the characters of the receiver from the one at a given index to the end.
Source§

fn m_substring_with_range(&self, range: NSRange) -> NSString

Returns a string object containing the characters of the receiver that lie within a given range.
Source§

fn m_substring_to_index(&self, to: UInt) -> NSString

Returns a new string containing the characters of the receiver up to, but not including, the one at a given index.
Source§

fn p_decomposed_string_with_canonical_mapping(&self) -> NSString

A string made by normalizing the string’s contents using the Unicode Normalization Form D.
Source§

fn p_decomposed_string_with_compatibility_mapping(&self) -> NSString

A string made by normalizing the receiver’s contents using the Unicode Normalization Form KD.
Source§

fn p_precomposed_string_with_canonical_mapping(&self) -> NSString

A string made by normalizing the string’s contents using the Unicode Normalization Form C.
Source§

fn p_precomposed_string_with_compatibility_mapping(&self) -> NSString

A string made by normalizing the receiver’s contents using the Unicode Normalization Form KC.
Source§

fn m_string_by_folding_with_options_locale( &mut self, options: NSStringCompareOptions, locale: &NSLocale, ) -> NSString

Creates a string suitable for comparison by removing the specified character distinctions from a string.
Source§

fn m_string_by_applying_transform_reverse( &mut self, transform: NSStringTransform, reverse: bool, ) -> Option<NSString>

Returns a new string made by appending to the receiver a given string. Read more
Source§

fn m_contains_string<S>(&self, other: S) -> bool
where S: INSString,

Returns a boolean value indicating whether the string contains a given string by performing a case-sensitive, locale-unaware search. Read more
Source§

fn p_available_string_encodings() -> *const Encoding

Returns a zero-terminated list of the encodings string objects support in the application’s environment.
Source§

fn p_default_cstring_encoding() -> Encoding

Returns the C-string encoding assumed for any method accepting a C string as an argument.
Source§

fn m_can_be_converted_to_encoding(&self, encoding: Encoding) -> bool

Returns a Boolean value that indicates whether the receiver can be converted to a given encoding without loss of information.
Source§

fn m_data_using_encoding(&self, encoding: Encoding) -> NSData

Returns an NSData object containing a representation of the receiver encoded using a given encoding.
Source§

impl PNSObject for NSString

Source§

fn m_class<'a>() -> &'a Class

Returns the class object for the receiver’s class.
Source§

fn m_self(&self) -> id

Returns the receiver.
Source§

fn m_new() -> Self
where Self: Sized + FromId,

Allocates a new instance of the receiving class, sends it an init message, and returns the initialized object.
Source§

fn m_alloc() -> Self
where Self: Sized + FromId,

Returns a new instance of the receiving class.
Source§

fn m_initialize()

Initializes the class before it receives its first message.
Source§

fn ip_superclass<'a>() -> Option<&'a Class>

Returns the class object for the receiver’s superclass.
Source§

fn m_is_equal(&self, object: &Self) -> bool

Returns a Boolean value that indicates whether the receiver and a given object are equal.
Source§

fn p_hash(&self) -> UInt

Returns an integer that can be used as a table address in a hash table structure.
Source§

fn m_is_kind_of_class(&self, class: Class) -> bool

Returns a Boolean value that indicates whether the receiver is an instance of given class or an instance of any class that inherits from that class.
Source§

fn m_is_member_of_class(&self, class: Class) -> bool

Returns a Boolean value that indicates whether the receiver is an instance of a given class.
Source§

fn m_responds_to_selector(&self, selector: Sel) -> bool

Returns a Boolean value that indicates whether the receiver implements or inherits a method that can respond to a specified message.
Source§

fn m_conforms_to_protocol(&self, protocol: Protocol) -> bool

Returns a Boolean value that indicates whether the receiver conforms to a given protocol.
Source§

fn p_description(&self) -> NSString

A textual representation of the receiver.
Source§

fn p_debug_description(&self) -> NSString

A textual representation of the receiver to use with a debugger.
Source§

fn m_perform_selector(&self, selector: Sel) -> id

Sends a specified message to the receiver and returns the result of the message.
Source§

fn m_perform_selector_with_object(&self, selector: Sel, with_object: id) -> id

Sends a message to the receiver with an object as the argument.
Source§

fn m_is_proxy(&self) -> bool

Returns a Boolean value that indicates whether the receiver does not descend from NSObject.
Source§

impl PartialEq<&str> for NSString

Source§

fn eq(&self, other: &&str) -> bool

Checks if a NSString is equal to a &str.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for NSString

Source§

fn eq(&self, other: &Self) -> bool

Checks if two NSStrings are equal.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToId for NSString

Source§

fn to_id(self) -> id

Returns id representation of the object.
Source§

impl Eq for NSString

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.