A collection of spatial input events that target a specific view.
You receive a structure of this type as an input to the
``Gesture/onChanged(_:)`` or ``Gesture/onEnded(_:)`` method of a
``SpatialEventGesture``. The structure contains a collection of
``SpatialEventCollection/Event`` values that correspond to ongoing
input events. You can look up a specific event in the collection by its
``SpatialEventCollection/Event/id`` value or iterate over all events in
the collection to apply logic depending on the event's state.
Members (6)
get · iOS 18.0+
startIndex
TypeScript
get startIndex(): SpatialEventCollection_Index
Swift declaration
var startIndex: SpatialEventCollection.Index { get }
The position of the first element in a nonempty collection.
If the collection is empty, `startIndex` is equal to `endIndex`.
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`.
get · iOS 18.0+
endIndex
TypeScript
get endIndex(): SpatialEventCollection_Index
Swift declaration
var endIndex: SpatialEventCollection.Index { 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(position: SpatialEventCollection.Index) -> SpatialEventCollection.Event { 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)