---
title: "track(withTrackID:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avcomposition/track(withtrackid:)"
---

# track(withTrackID:)

Returns a track that contains the specified identifier.

## Declaration

```swift
func track(withTrackID trackID: CMPersistentTrackID) -> AVCompositionTrack?
```

## Parameters

- `trackID`: The identifier of the track to retrieve.

## Return Value

Return Value A composition track, or nil if no track with the identifier exists.

## Discussion

Discussion Apple discourages using this method in iOS 15, tvOS 15, macOS 12, and watchOS 8 or later. Load a track asynchronously using loadTrack(withTrackID:completionHandler:) instead.

## See Also

### Accessing tracks

- [tracks](avfoundation/avcomposition/tracks.md)
- [tracks(withMediaType:)](avfoundation/avcomposition/tracks(withmediatype:).md)
- [tracks(withMediaCharacteristic:)](avfoundation/avcomposition/tracks(withmediacharacteristic:).md)
- [unusedTrackID()](avfoundation/avcomposition/unusedtrackid().md)
