startIndex
TypeScriptget startIndex(): numberSwift declarationvar startIndex: Int { get }The position of the first element in a nonempty collection. If the collection is empty, `startIndex` is equal to `endIndex`.
struct · iOS 17.0+ · SDK 27.1
struct RunSliceA slice of a run of placed glyphs in a text layout.
get startIndex(): numberSwift declarationvar startIndex: Int { get }The position of the first element in a nonempty collection. If the collection is empty, `startIndex` is equal to `endIndex`.
get characterIndices(): Array<Text_Layout_CharacterIndex>Swift declarationvar characterIndices: [Text.Layout.CharacterIndex] { get }The array of character indices corresponding to the glyphs in `self`.
get typographicBounds(): Text_Layout_TypographicBoundsSwift declarationvar typographicBounds: Text.Layout.TypographicBounds { get }The typographic bounds of the partial run of glyphs.
static init(run: Text_Layout_Run, indices: SDKHandle): Text_Layout_RunSliceSwift declarationinit(run: Text.Layout.Run, indices: Range<Int>)get run(): Text_Layout_RunSwift declarationvar run: Text.Layout.Runset run(value: Text_Layout_Run)Swift declarationvar run: Text.Layout.Runget indices(): SDKHandleSwift declarationvar indices: Range<Int>The indices that are valid for subscripting the collection, in ascending order. A collection's `indices` property can hold a strong reference to the collection itself, causing the collection to be nonuniquely referenced. If you mutate the collection while iterating over its indices, a strong reference can result in an unexpected copy of the collection. To avoid the unexpected copy, use the `index(after:)` method starting with `startIndex` to produce indices instead. var c = MyFancyCollection([10, 20, 30, 40, 50]) var i = c.startIndex while i != c.endIndex { c[i] /= 5 i = c.index(after: i) } // c == MyFancyCollection([2, 4, 6, 8, 10])
set indices(value: SDKHandle)Swift declarationvar indices: Range<Int>The indices that are valid for subscripting the collection, in ascending order. A collection's `indices` property can hold a strong reference to the collection itself, causing the collection to be nonuniquely referenced. If you mutate the collection while iterating over its indices, a strong reference can result in an unexpected copy of the collection. To avoid the unexpected copy, use the `index(after:)` method starting with `startIndex` to produce indices instead. var c = MyFancyCollection([10, 20, 30, 40, 50]) var i = c.startIndex while i != c.endIndex { c[i] /= 5 i = c.index(after: i) } // c == MyFancyCollection([2, 4, 6, 8, 10])
get endIndex(): numberSwift declarationvar endIndex: Int { get }The collection's "past the end" position---that is, the position one greater than the last valid subscript argument. When you need a range that includes the last element of a collection, use the half-open range operator (`..<`) with `endIndex`. The `..<` operator creates a range that doesn't include the upper bound, so it's always safe to use with `endIndex`. For example: let numbers = [10, 20, 30, 40, 50] if let index = numbers.firstIndex(of: 30) { print(numbers[index ..< numbers.endIndex]) } // Prints "[30, 40, 50]" If the collection is empty, `endIndex` is equal to `startIndex`.
subscript(index: number): Text_Layout_RunSliceSwift declarationsubscript(index: Int) -> Text.Layout.RunSlice { get }Accesses the element at the specified position. The following example accesses an element of an array through its subscript to print its value: var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] print(streets[1]) // Prints "Bryant" You can subscript a collection with any valid index other than the collection's end index. The end index refers to the position one past the last element of a collection, so it doesn't correspond with an element. - Parameter position: The position of the element to access. `position` must be a valid index of the collection that is not equal to the `endIndex` property. - Complexity: O(1)
subscript39744(bounds: SDKHandle): Text_Layout_RunSliceSwift declarationsubscript(bounds: Range<Int>) -> Text.Layout.RunSlice { get }Accesses a contiguous subrange of the collection's elements. For example, using a `PartialRangeFrom` range expression with an array accesses the subrange from the start of the range expression until the end of the array. let streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] let streetsSlice = streets[2..<5] print(streetsSlice) // ["Channing", "Douglas", "Evarts"] The accessed slice uses the same indices for the same elements as the original collection. This example searches `streetsSlice` for one of the strings in the slice, and then uses that index in the original array. let index = streetsSlice.firstIndex(of: "Evarts")! // 4 print(streets[index]) // "Evarts" Always use the slice's `startIndex` property instead of assuming that its indices start at a particular value. Attempting to access an element by using an index outside the bounds of the slice may result in a runtime error, even if that index is valid for the original collection. print(streetsSlice.startIndex) // 2 print(streetsSlice[2]) // "Channing" print(streetsSlice[0]) // error: Index out of bounds - Parameter bounds: A range of the collection's indices. The bounds of the range must be valid indices of the collection. - Complexity: O(1)
1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
Text.Layout.RunSlice.subscript(_:)
Passing a Swift type itself is not supported.