---
title: "addTrackAssociation(withTrackOf:type:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avassetwriterinput/addtrackassociation(withtrackof:type:)"
---

# addTrackAssociation(withTrackOf:type:)

Adds an association between input tracks.

## Declaration

```swift
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

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.

## See Also

### Configuring track associations

- [canAddTrackAssociation(withTrackOf:type:)](avfoundation/avassetwriterinput/canaddtrackassociation(withtrackof:type:).md)
