<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ModelIO",
  "identifier" : "/documentation/ModelIO/MDLObject/addChild(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Model I/O"
    ],
    "preciseIdentifier" : "c:objc(cs)MDLObject(im)addChild:"
  },
  "title" : "addChild(_:)"
}
-->

# addChild(_:)

Adds a child object to this object, creating a container for the object’s children if necessary.

```
func addChild(_ child: MDLObject)
```

## Parameters

`child`

The child object to add.

## Discussion

Many asset formats describe a hierarchy of transforms that model the spatial relationships between meshes, lights, and cameras in the asset. In such formats, hierarchic transforms are [`MDLObject`](/documentation/ModelIO/MDLObject) instances whose [`children`](/documentation/ModelIO/MDLObject/children) property references the objects affected by the transform—and those objects can be other [`MDLObject`](/documentation/ModelIO/MDLObject) instances with children of their own.

If the object’s [`children`](/documentation/ModelIO/MDLObject/children) property is `nil`, this method sets that property to a new [`MDLObjectContainer`](/documentation/ModelIO/MDLObjectContainer) instance before adding the child object.

---

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)