Objective C Text and strings - Objective C

What is Text and strings in Objective C?

NSString class is used to store strings and texts in Objective-C. NSCharacterSet represents various groupings of characters that are used by the NSString and NSScanner classes.

NSCharacterSet

The set of methods available in NSCharacterSet that represent the various character sets.

  • alphanumericCharacterSet - Returns a character set containing the characters in the categories Letters, Marks, and Numbers.
  • capitalizedLetterCharacterSet - Returns a character set containing the characters in the category of Titlecase Letters.
  • characterSetWithCharactersInString - Returns a character set containing the characters in a given string.
  • characterSetWithRange: - Returns a character set containing characters with Unicode values in a given range.
  • illegalCharacterSet - Returns a character set containing values in the category of Non-Characters or that have not yet been defined in version 3.2 of the Unicode standard.
  • letterCharacterSet - Returns a character set containing the characters in the categories Letters and Marks.
  • lowercaseLetterCharacterSet - Returns a character set containing the characters in the category of Lowercase Letters.
  • newlineCharacterSet - Returns a character set containing the newline characters.
  • punctuationCharacterSet - Returns a character set containing the characters in the category of Punctuation.
  • symbolCharacterSet - Returns a character set containing the characters in the category of Symbols. uppercaseLetterCharacterSet - Returns a character set containing the characters in the categories of Uppercase Letters and Titlecase Letters.
  • whitespaceAndNewlineCharacterSet - Returns a character set containing Unicode General Category Z*, U000A ~ U000D, and U0085.
  • whitespaceCharacterSet - Returns a character set containing only the in-line whitespace characters space (U+0020) and tab (U+0009).

On compiling and executing the above code, the following result is produced:

The above program is an example of using NSCharacterSet. Here, punctuations on both sides of the given strings are trimmed.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Objective C Topics