---
title: "segment(forTrackTime:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avassettrack/segment(fortracktime:)"
---

# segment(forTrackTime:)

Retrieves a segment with a target time range that contains, or is closest to, the specified track time.

## Declaration

```swift
func segment(forTrackTime trackTime: CMTime) -> AVAssetTrackSegment?
```

## Parameters

- `trackTime`: The track time for which you want the segment.

## Return Value

Return Value The track segment matching, or closest to, the specied time.

## Discussion

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