<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/Scene/AnchorCollection",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation5SceneC16AnchorCollectionV"
  },
  "title" : "Scene.AnchorCollection"
}
-->

# Scene.AnchorCollection

A collection of anchor entities.

```
@MainActor @preconcurrency struct AnchorCollection
```

## Topics

### Iterating over the collection

[`makeIterator()`](/documentation/RealityKit/Scene/AnchorCollection/makeIterator())

Returns an iterator over the elements of the collection.

[`Scene.AnchorCollection.Iterator`](/documentation/RealityKit/Scene/AnchorCollection/Iterator)

An iterator that presents the elements of the collection.

[`Scene.AnchorCollection.Element`](/documentation/RealityKit/Scene/AnchorCollection/Element)

The type of element traversed by the iterator.

### Counting anchors

### Accessing anchors

[`subscript(_:)`](/documentation/RealityKit/Scene/AnchorCollection/subscript(_:))

Accesses the element at the specified position.

[`Scene.AnchorCollection.SubSequence`](/documentation/RealityKit/Scene/AnchorCollection/SubSequence)

A sequence that represents a contiguous subrange of the collection’s
elements.

### Adding anchors

[`append(_:)`](/documentation/RealityKit/Scene/AnchorCollection/append(_:))

Adds a new anchor at the end of the collection.

[`append(contentsOf:)`](/documentation/RealityKit/Scene/AnchorCollection/append(contentsOf:)-3bjib)

Adds anchors from an array to the end of this collection.

[`append(contentsOf:)`](/documentation/RealityKit/Scene/AnchorCollection/append(contentsOf:)-4sf55)

Adds anchors from a sequence to the end of this collection.

### Removing anchors

[`remove(_:)`](/documentation/RealityKit/Scene/AnchorCollection/remove(_:))

Removes the anchor at the specified position.

[`remove(at:)`](/documentation/RealityKit/Scene/AnchorCollection/remove(at:))

Removes and returns the anchor at the specified position.

[`removeAll()`](/documentation/RealityKit/Scene/AnchorCollection/removeAll())

Removes all anchors from the collection.

[`removeAll(keepCapacity:)`](/documentation/RealityKit/Scene/AnchorCollection/removeAll(keepCapacity:))

Removes all anchors from the collection.

### Replacing anchors

[`replaceAll(_:)`](/documentation/RealityKit/Scene/AnchorCollection/replaceAll(_:)-tris)

Replaces the existing anchor collection with a provided collection.

[`replaceAll(_:)`](/documentation/RealityKit/Scene/AnchorCollection/replaceAll(_:)-5t195)

Replaces the existing anchor collection with a provided sequence.

### Finding anchors

### Selecting anchors

### Transforming anchors

### Reordering anchors

### Excluding anchors

### Manipulating indices

[`Scene.AnchorCollection.Index`](/documentation/RealityKit/Scene/AnchorCollection/Index)

A type that represents a position in the collection.

[`startIndex`](/documentation/RealityKit/Scene/AnchorCollection/startIndex)

The position of the first element in a nonempty collection.

[`endIndex`](/documentation/RealityKit/Scene/AnchorCollection/endIndex)

The position one greater than the last valid subscript argument.

[`index(after:)`](/documentation/RealityKit/Scene/AnchorCollection/index(after:))

Returns the position immediately after the given index.

### Describing the collection

[`description`](/documentation/RealityKit/Scene/AnchorCollection/description)

A textual representation of this instance.



---

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)