<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMTag-swift.class/value(onlyIfMatching:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "s:9CoreMedia5CMTagC5value14onlyIfMatchingxSgAA10CMTypedTagC8CategoryVyx_G_ts8SendableRzlF"
  },
  "title" : "value(onlyIfMatching:)"
}
-->

# value(onlyIfMatching:)

Retrieves a tag’s value as a specific type, if and only if it matches a category.

```
func value<T>(onlyIfMatching category: CMTypedTag<T>.Category) -> T? where T : Sendable
```

## Parameters

`category`

The category to check if the tag contains.

## Return Value

The value contained in the tag as an instance of type `T` if the category matches. Otherwise, returns `nil`.

---

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)