One Logo Pool Ball
SwiftUICore · IOS API REFERENCE

SubviewsCollection

struct · iOS 18.0+ · SDK 27.1

struct SubviewsCollection

An opaque collection representing the subviews of view. Subviews collection constructs subviews on demand, so only access the part of the collection you need to create the resulting content. You can get access to a view's subview collection by using the ``Group/init(sectionsOf:transform:)`` initializer. The collection's elements are the pieces that make up the given view, and the collection as a whole acts as a proxy for the original view.

Members (6)

get · iOS 18.0+

startIndex

TypeScript
get startIndex(): number
Swift declaration
var startIndex: Int { get }

The position of the first element in a nonempty collection. If the collection is empty, `startIndex` is equal to `endIndex`.

method · iOS 18.0+

index

TypeScript
indexAfter(i: number): number
Swift declaration
func index(after i: Int) -> Int

Returns the position immediately after the given index. The successor of an index must be well defined. For an index `i` into a collection `c`, calling `c.index(after: i)` returns the same index every time. - Parameter i: A valid index of the collection. `i` must be less than `endIndex`. - Returns: The index value immediately after `i`.

method · iOS 18.0+

index

TypeScript
indexBefore(i: number): number
Swift declaration
func index(before i: Int) -> Int

Returns the position immediately before the given index. - Parameter i: A valid index of the collection. `i` must be greater than `startIndex`. - Returns: The index value immediately before `i`.

get · iOS 18.0+

endIndex

TypeScript
get endIndex(): number
Swift declaration
var 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 · iOS 18.0+

subscript

TypeScript
subscript(bounds: SDKHandle): SubviewsCollectionSlice
Swift declaration
subscript(bounds: Range<Int>) -> SubviewsCollectionSlice { get }

Accesses a contiguous subrange of the collection's elements. The accessed slice uses the same indices for the same elements as the original collection uses. Always use the slice's `startIndex` property instead of assuming that its indices start at a particular value. This example demonstrates getting a slice of an array of strings, finding the index of one of the strings in the slice, and then using that index in the original array. let streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] let streetsSlice = streets[2 ..< streets.endIndex] print(streetsSlice) // Prints "["Channing", "Douglas", "Evarts"]" let index = streetsSlice.firstIndex(of: "Evarts") // 4 print(streets[index!]) // Prints "Evarts" - Parameter bounds: A range of the collection's indices. The bounds of the range must be valid indices of the collection. - Complexity: O(1)

subscript · iOS 18.0+

subscript

TypeScript
subscript49574(index: number): Subview
Swift declaration
subscript(index: Int) -> Subview { 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)

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUICore types →