# How to dynamically change the visible captions on iOS

This article describes how you can dynamically change the currently selected subtitle or closed captions language, or how you can set a default language.

This article assumes that you are using text tracks that are loaded with the manifest. If you add the text track separately, you can also mark it as the default track when you configure your source.

The examples below match tracks on their `language` property, which contains the ISO language code of the track. If that is not sufficient for your use case, for example when a stream contains multiple tracks with the same language, you can match on the track's `label` instead, which contains the human-readable name shown in your UI.

## Usage

The function below enables the text track with the requested language.

```swift
private func setLanguage(player: THEOplayer, language: String) {
    let list: TextTrackList = player.textTracks
    for i in 0..<list.count {
        let textTrack: TextTrack = list[i]
        textTrack.mode = textTrack.language == language ? .showing : .disabled
    }
}
```

## Related articles

* [How to programmatically detect text tracks](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/how-to-guides/ios/text-tracks/detect-text-tracks.md)
* [How to programmatically enable or disable text tracks](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/how-to-guides/ios/text-tracks/enable-disable-text-tracks.md)
* [How to insert subtitles](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/how-to-guides/ios/text-tracks/insert-subtitles.md)
