<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/SpatialEventCollection",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI22SpatialEventCollectionV"
  },
  "title" : "SpatialEventCollection"
}
-->

# SpatialEventCollection

A collection of spatial input events that target a specific view.

```
struct SpatialEventCollection
```

## Overview

You receive a structure of this type as an input to the
[`onChanged(_:)`](/documentation/SwiftUI/Gesture/onChanged(_:)) or [`onEnded(_:)`](/documentation/SwiftUI/Gesture/onEnded(_:)) method of a
[`SpatialEventGesture`](/documentation/SwiftUI/SpatialEventGesture). The structure contains a collection of
[`SpatialEventCollection.Event`](/documentation/SwiftUI/SpatialEventCollection/Event) values that correspond to ongoing
input events. You can look up a specific event in the collection by its
[`id`](/documentation/SwiftUI/SpatialEventCollection/Event/id-swift.property) value or iterate over all events in
the collection to apply logic depending on the event’s state.

## Topics

### Accessing the collection’s events

[`struct Event`](/documentation/SwiftUI/SpatialEventCollection/Event)

A spatial event generated from an input like a touch or click
that can drive gestures in the system.

[`subscript(SpatialEventCollection.Event.ID) -> SpatialEventCollection.Event?`](/documentation/SwiftUI/SpatialEventCollection/subscript(_:))

Retrieves an event using its unique identifier.

### Iterating over events in the collection

[`func makeIterator() -> SpatialEventCollection.Iterator`](/documentation/SwiftUI/SpatialEventCollection/makeIterator())

Makes an iterator over all events in the collection.

[`struct Iterator`](/documentation/SwiftUI/SpatialEventCollection/Iterator)

An iterator over all events in the collection.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Collection`](/documentation/Swift/Collection)

[`Sequence`](/documentation/Swift/Sequence)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)