<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKQuadtree/add(_:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKQuadtree(im)addElement:withQuad:"
  },
  "title" : "add(_:in:)"
}
-->

# add(_:in:)

Adds an object to the tree corresponding to the specified region of 2D space.

```
func add(_ element: ElementType, in quad: GKQuad) -> GKQuadtreeNode
```

## Parameters

`element`

The object to add to the tree.

`quad`

The axis-aligned bounding region in 2D space to which the object corresponds.

## Return Value

The tree node containing the newly added object.

## Discussion

The [`GKQuadtree`](/documentation/GameplayKit/GKQuadtree) class automatically creates nodes to manage the objects you add to the tree. If you expect to remove an element you’ve added, keep a reference to the node this method returns so you can use the [`remove(_:using:)`](/documentation/GameplayKit/GKQuadtree/remove(_:using:)) method to remove that object quickly.

---

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)