A position of a character or code unit in a string.
SDK
- Xcode 9.0+
Framework
- Swift Standard Library
A position of a character or code unit in a string.
SDK
Framework
init?(String .Index, within: String .UTF16View)
Creates an index in the given UTF-16 view that corresponds exactly to the specified string position.
init?(String .Index, within: String .UTF8View)
Creates an index in the given UTF-8 view that corresponds exactly to the specified UTF16View
position.
init?(String .Index, within: String)
Creates an index in the given string that corresponds exactly to the specified position.
init?(String .Index, within: String .Unicode Scalar View)
Creates an index in the given Unicode scalars view that corresponds exactly to the specified UTF16View
position.
init?<S>(String .Index, within: S)
Creates an index in the given string that corresponds exactly to the specified position.
init<S>(utf16Offset: Int, in: S)
Creates a new index at the specified UTF-16 code unit offset
var hash Value: Int
The hash value.
func hash(into: inout Hasher)
Hashes the essential components of this value by feeding them into the given hasher.
func same Position(in: String) -> String .Index?
Returns the position in the given string that corresponds exactly to this index.
func same Position(in: String .UTF8View) -> String .UTF8View .Index?
Returns the position in the given UTF-8 view that corresponds exactly to this index.
func same Position(in: String .Unicode Scalar View) -> String .Unicode Scalar Index?
Returns the position in the given view of Unicode scalars that corresponds exactly to this index.
func same Position(in: String .UTF16View) -> String .UTF16View .Index?
Returns the position in the given UTF-16 view that corresponds exactly to this index.
func utf16Offset<S>(in: S) -> Int
The UTF-16 code unit offset corresponding to this Index
static func != (String .Index, String .Index) -> Bool
Returns a Boolean value indicating whether two values are not equal.
static func ... (String .Index) -> Partial Range From<String .Index>
Returns a partial range extending upward from a lower bound.
static func ... (String .Index) -> Partial Range Through<String .Index>
Returns a partial range up to, and including, its upper bound.
static func ... (String .Index, String .Index) -> Closed Range<String .Index>
Returns a closed range that contains both of its bounds.
static func ..< (String .Index) -> Partial Range Up To<String .Index>
Returns a partial range up to, but not including, its upper bound.
static func ..< (String .Index, String .Index) -> Range<String .Index>
Returns a half-open range that contains its lower bound but not its upper bound.
static func < (String .Index, String .Index) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.
static func <= (String .Index, String .Index) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func == (String .Index, String .Index) -> Bool
Returns a Boolean value indicating whether two values are equal.
static func > (String .Index, String .Index) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (String .Index, String .Index) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
struct Substring
A slice of a string.
protocol String Protocol
A type that can represent a string as a collection of characters.
struct String .Unicode Scalar View
A view of a string’s contents as a collection of Unicode scalar values.
struct String .UTF16View
A view of a string’s contents as a collection of UTF-16 code units.
struct String .UTF8View
A view of a string’s contents as a collection of UTF-8 code units.
struct String .Iterator
A type that provides the collection’s iteration interface and encapsulates its iteration state.