<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVAssetWriterInput/addTrackAssociation(withTrackOf:type:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAssetWriterInput(im)addTrackAssociationWithTrackOfInput:type:"
  },
  "title" : "addTrackAssociation(withTrackOf:type:)"
}
-->

# addTrackAssociation(withTrackOf:type:)

Adds an association between input tracks.

```
func addTrackAssociation(withTrackOf input: AVAssetWriterInput, type trackAssociationType: String)
```

## Parameters

`input`

The input that contains the track to associate with this input’s track.

`trackAssociationType`

The type of track association to add.

## Discussion

The system raises an error if the association type requires tracks of a media type that doesn’t match the input’s type, or if the output file type doesn’t support track associations.

You can’t add track associations after writing starts.

---

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)