Title: Theory / Important / CS / Programming / Objective-C / Library / NS / String

Typ: NSString
Meaning: String
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/DefiningClasses/DefiningClasses.html
Language: Objective-C

Typ: NSMutableString
Meaning: A mutable string
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/DefiningClasses/DefiningClasses.html
Language: Objective-C

Instruction: @"foo"
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/DefiningClasses/DefiningClasses.html
Language: objective-C
Returns: the NSString with content foo

Instruction: SystUTF8ToNSSTring(utf8_string)
Language: Objective-C
Returns: utf8_string, encodedded as a NSString
Variables: StringPiece utf8_string

Instruction: SystUTF16ToNSSTring(utf16_string)
Language: Objective-C
Returns: utf16_string, encodedded as a NSString
Variables: StringPiece16 utf16_string

Instruction: SysNSStringToUTF8(string)
Language: Objective-C
Returns: string, encoded as a std::string
Variables: NSString string

Instruction: SysNSStringToUTF16(std_string)
Language: Objective-C
Returns: string, encodedded as a string16
Variables: NSString string

Instruction: NSStringFromRange(range)
Page: https://developer.apple.com/documentation/foundation/nsrange?language=objc
Language: Objective-C
Returns: "{location,range}"
Variables: NSRange range
Typ: NSRange

Question: How to subclass NSString
Answer: You must implements length and characterAtIndex
Context: Objective-C
Answer2: It is recommended to override getCharacters:range:

Question: How to subclass NSMutableString
Answer: Same as subclassing NSString plus replaceCharcatersInRange:withString
Context: Objective-C

Instruction: [NSMutableString
  stringWithCapacitiy:capacity
]
[[NSMutableString alloc]
  stringWithCapacitiy:capacity
]
Page: https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc
Language: Objective-C
Returns: an empty NSMutableString object with initial storage for a given number of characters.
Variables: NSMutableString string

Instruction: [string
  appendFormat:format
  ...
]
Page: https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc
Effect: Add format formatted to string
Language: Objective-C
Variables: NSMutableString string

Instruction: [string
  appendString:other
]
Page: https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc
Effect: Add other to string
Language: Objective-C
Variables: NSMutableString string

Instruction: [string
  applyTransform:transform
  reverse:reverse
  range:range
  updatedRange:resultingRange
]
Page: https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc
Effect: Transliterates the receiver by applying a specified ICU string transform.
Language: Objective-C
Variables: NSMutableString string

Instruction: [string
  deleteCharactersInRange:range
]
Page: https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc
Effect: Remove range from string
Language: Objective-C
Variables: NSMutableString string

Instruction: [string
  insertString:string
  atIndex:loc
]
Page: https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc
Effect: Add string at index loc
Language: Objective-C
Variables: NSMutableString string

Instruction: [string
  replaceCharactersInRange:range
  withString:other
]
Page: https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc
Effect: remove range and add other instead in string
Language: Objective-C
Variables: NSMutableString string

Instruction: [string
  replaceOccurencesOfString:target
  withString:replace
  options:options
  range:searchRange
]
Page: https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc
Effect: Replace, in string's searchRange, target by replace. Search method according to options
Language: Objective-C
Returns: Number of replacement made
Variables: NSMutableString string

Instruction: [string
  setString:other
]
Page: https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc
Effect: Replace string content by other
Language: Objective-C
Variables: NSMutableString string

Instruction: [NSString string]
[[NSString alloc] init]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: An empty string

Instruction: [[NSString alloc]
  initWithBytes:bytes
  length:len
  encoding:encoding
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: an initialized NSString object containing a given number of bytes from a given buffer of bytes interpreted in a given encoding.

Instruction: [[NSString alloc]
  initWithBytes:bytes
  length:len
  encoding:encoding
  freeWhenDone:freeBuffer
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
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.

Instruction: [[NSString alloc]
  initWithCharacters:characters
  length:len
]
[NSString
  stringWithCharacters:characters
  length:len
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: An initialized NSString object that contains a given number of characters from a given C array of UTF-16 code units.

Instruction: [[NSString alloc]
  initWithCharactersNoCopy:characters
  length:len
  freeWhenDone:freeBuffer
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: an initialized NSString object that contains a given number of characters from a given C array of UTF-16 code units.

Instruction: [[NSString alloc]
  initWithString:aString
]
[NSString
  stringWithString:aString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: an NSString object initialized by copying the characters from another given string.

Instruction: [[NSString alloc]
  initWithCString:nullTerminatedString
  encoding:encoding
]
[NSString
  stringWithCString:nullTerminatedString
  encoding:encoding
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: An NSString object initialized using the characters in a given C array, interpreted according to a given encoding.

Instruction: [[NSString alloc]
  initWithUTF8String:nullTerminatedString
]
[NSString
  stringWithUTF8String:nullTerminatedString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: an NSString object initialized by copying the characters from a given C array of UTF8-encoded bytes.

Instruction: [[NSString alloc]
  initWithFormat:format,...
]
[NSString stringWithFormat:format,...
]
[[NSString alloc]
  initWithFormat:format,
  arguments:argList
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: An NSString object initialized by using a given format string as a template into which the remaining argument values are substituted.

Variable: string.length
Meaning: The number of UTF-16 code units in string
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Variables: NSString string

Instruction: [string
  lengthOfBytesUsingEncoding:enc
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Returns the number of bytes required to store string in a given encoding.
Variables: NSString string

Instruction: [string
  characterAtIndex:index
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: the index-th character
Variables: NSString string

Instruction: [string
  getCharacters:buffer
  range:range
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Copies characters from range in string to the buffer
Variables: NSString string

Instruction: [string
  cStringUsingEncoding:encoding
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string considered as a c-string
Variables: NSString string

Instruction: [string
  getCString:buffer
  maxLength:maxBufferCount
  encoding:encoding
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Effect: Convert the strings to encoding and store it in buffer
Language: Objective-C
Variables: NSString string

Variable: string.UTF8String
Meaning: string as UTF8String c-string null terminated
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Variables: NSString string

Instruction: [string
  caseInsensitiveCompare:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: A NSComparisonResult comparing case insensitive string and otherString
Variables: NSString string

Instruction: [string
  localizedCaseInsensitiveCompare:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: A NSComparisonResult comparing string and otherString as localized and case insensitive
Variables: NSString string

Instruction: [string
  compare:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: A NSComparisonResult comparing string and otherString case sensitive
Variables: NSString string

Instruction: [string
  localizedCompare:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: A NSComparisonResult comparing localized string and otherString case sensitive
Variables: NSString string

Instruction: [string
  hasPrefix:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Whether otherString is a prefix of string
Variables: NSString string

Instruction: [string
  hasSuffix:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Whether otherString is a suffix of string
Variables: NSString string

Instruction: [string
  isEqualToString:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Whether otherString equals string
Variables: NSString string

Instruction: [string
  stringByAppendingString:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: The concatenation of string and otherString
Variables: NSString string

Instruction: [string
  stringByAppendingFormat:otherString, ...
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: The concatenation of string and (otherString formatted)
Variables: NSString string

Instruction: [string
  stringByPaddingToLength:newLength
  withString:padString
  startingAtIndex:padIndex
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string , of length newLength, either by truncating the end or adding as many copy of padString as necessary.
Variables: NSString string

Instruction: [string
  lowercaseString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as lower case, non localized
Variables: NSString string

Instruction: [string
  localizedLowercaseString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as localized lower case
Variables: NSString string

Instruction: [string
  lowercaseStringWithLocale:locale
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as localized in locale lower case
Variables: NSString string

Instruction: [string
  uppercaseStringWithLocale:locale
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as localized in locale upper case
Variables: NSString string

Instruction: [string
  localeUppercaseString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as localized upper case
Variables: NSString string

Instruction: [string
  uppercaseString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as non localized upper case
Variables: NSString string

Instruction: [string
  capitalizedString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: String capitalized. I.e. with the first character in each word changed to its corresponding uppercase value, and all remaining characters set to their corresponding lowercase values
Variables: NSString string

Instruction: [string
  localizedCapitalizedString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: String locally capitalized
Variables: NSString string

Instruction: [string
  capitalizedStringWithlocale:locale
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: String locally capitalized with local
Variables: NSString string

Instruction: [string
  componentsSeparatedByString:separator
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Array of string splitted by separator
Variables: NSString string

Instruction: [string
  componentsSeparatedByCharactersInSet:separators
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Array of string splitted by any characters of separators
Variables: NSString string

Instruction: [string
  stringByTrimmingCharactersInSet:set
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string with prefix and suffix that are contained in set trimmed
Variables: NSString string

Instruction: [string
  substringFromIndex:from
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Suffix of string starting at from
Variables: NSString string

Instruction: [string
  substringWithRange:range
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: substring of string at range
Variables: NSString string

Instruction: [string
  substringToIndex:to
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Prefix of string up until to
Variables: NSString string

Instruction: [string
  decomposedStringWithCanonicalMapping
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string normalized with Unicode Form D
Variables: NSString string

Instruction: [string
  decomposedStringWithCompatibilityMapping
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string normalized with Unicode Form KD
Variables: NSString string

Instruction: [string
  precomposedStringWithCanonicalMapping
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string normalized with Unicode Form C
Variables: NSString string

Instruction: [string
  precomposedStringWithCompatibilityMapping
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string normalized with Unicode Form KC
Variables: NSString string

Instruction: [string
  stringByFoldingWithOptions:options
  locale:locale
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: A string created by performing a character folding operation with the specified options and locale.
Variables: NSString string

Instruction: [string
  stringByApplyingTransform:transform
  reverse:reverse
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: a new string by applying a specified transform to the string.
Variables: NSString string

Instruction: [string
  containsString:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Whether string contains otherString case-sensitive, locale-unaware
Variables: NSString string

Instruction: [string
  localizedCaseInsensitiveContainsString:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Whether the string contains a given string by performing a case-insensitive, locale-aware search.
Variables: NSString string

Instruction: [string
  localizedStandardContainsString:otherString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: whether the string contains a given string by performing a case and diacritic insensitive, locale-aware search.
Variables: NSString string

Instruction: [string
  rangeOfCharacterFromSet:searchSet
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: the range in the string of the first character from a given character set
Variables: NSString string

Instruction: [string
  rangeOfString:searchString
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: the range of the first occurrence of a given string within the string.
Variables: NSString string

Instruction: [string
  rangeOfString:searchString
  options:mask
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: the range of the first occurrence of searchString, subject to given options.
Variables: NSString string

Instruction: [string
  doubleValue
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as a double
Variables: NSString string

Instruction: [string
  floatValue
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as a float
Variables: NSString string

Instruction: [string
  intValue
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as a int
Variables: NSString string

Instruction: [string
  integerValue
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as an NSInteger
Variables: NSString string

Instruction: [string
  longLongValue
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as a long long
Variables: NSString string

Instruction: [string
  boolValue
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string as a bool. I.e. starts with non-0 digit, y, Y, t, or T
Variables: NSString string

Instruction: [NSString
  pathWithComponents:components]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: a string built from the strings in a given array by concatenating them with a path separator between each pair.
Variables: NSString string

Instruction: [string
  pathComponents
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: the path string as an array of components
Variables: NSString string

Instruction: [string
  fileSystemRepresentation
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Effect: A file system-specific representation of string
Language: Objective-C
Variables: NSString string

Instruction: [string
  getFileSystemRepresentation:cname
  maxLength:max
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Effect: Interprets the receiver as a system-independent path and fills a buffer with a C-string in a format and encoding suitable for use with file-system calls.
Language: Objective-C
Returns: whether buffer is successfully filled with a file-system representation
Variables: NSString string

Instruction: [string
  absolutePath
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: Whether string is an absolute path
Variables: NSString string

Instruction: [string
  lastPathComponent
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: The last path component of the receiver.
Variables: NSString string, a path

Instruction: [string
  pathExtension
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: the extension of string
Variables: NSString string, a path

Instruction: [string
  stringByAbbreviatingWithTildeInPath
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string but replace home by ~
Variables: NSString string, a path

Instruction: [string
  stringByAppendingPathComponent:appended
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: "string/appended" , adding a separator between both if necessary
Variables: NSString string, a path

Instruction: [string
  stringByAppendingPathExtension:ext
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: "string.ext"
Variables: NSString string, a path

Instruction: [string
  stringByDeletingLastPathComponent
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string made by deleting the last path component from the receiver, along with any final path separator.
Variables: NSString string, a path

Instruction: [string
  stringByDeletingPathExtension
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: string made by deleting the extension (if any, and only the last) from the receiver.
Variables: NSString string, a path

Instruction: [string
  stringByExpandingTildeInPath
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: A new string made by expanding the initial component of the receiver to its full path value.
Variables: NSString string, a path

Instruction: [string
  stringByResolvingSymlinksInPath
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: A new string made from the receiver by resolving all symbolic links and standardizing path.
Variables: NSString string, a path

Instruction: [string
  stringByStandardizingPath
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: A new string made by removing extraneous path components from the receiver.
Variables: NSString string, a path

Instruction: [string
  stringsByAppendingPaths:paths
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: an array of strings made by separately appending to the receiver each string in a given array.
Variables: NSString string, a path

Instruction: [string
  stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: a new string made from the receiver by replacing all characters not in the specified set with percent-encoded characters.
Variables: NSString string, a path

Instruction: [string
  stringByRemovingPercentEncoding
]
Page: https://developer.apple.com/documentation/foundation/nsstring?language=objc
Language: Objective-C
Returns: a new string made from the receiver by replacing all percent encoded sequences with the matching UTF-8 characters.
Variables: NSString string, a path