NSRange

public extension NSRange
  • Range with 0 location and length

    Declaration

    Swift

    static var zero: NSRange { get }
  • Undocumented

    Declaration

    Swift

    var firstCharacterRange: NSRange { get }
  • Undocumented

    Declaration

    Swift

    var lastCharacterRange: NSRange { get }
  • Undocumented

    Declaration

    Swift

    var previousPosition: NSRange { get }
  • Undocumented

    Declaration

    Swift

    var nextPosition: NSRange { get }
  • Undocumented

    Declaration

    Swift

    var endLocation: Int { get }
  • Undocumented

    Declaration

    Swift

    var nextCharacterRange: NSRange { get }
  • Undocumented

    Declaration

    Swift

    var previousCharacterRange: NSRange? { get }
  • Converts the range to UITextRange in given UITextInput. Returns nil if the range is invalid in the UITextInput.

    Declaration

    Swift

    func toTextRange(textInput: UITextInput) -> UITextRange?

    Parameters

    textInput

    UITextInput to convert the range in.

  • Checks if the range is valid in given UITextInput

    Declaration

    Swift

    func isValidIn(_ textInput: UITextInput) -> Bool

    Parameters

    textInput

    UITextInput to validate the range in.

  • Shifts the range with given shift value

    Important

    The shifted range may or may not be valid in a given string. Validity of shifted range must always be checked at the usage site.

    Declaration

    Swift

    func shiftedBy(_ shift: Int) -> NSRange

    Parameters

    shift

    Int value to shift range by.

    Return Value

    Shifted range with same length.