---
title: "value(onlyIfMatching:)"
framework: coremedia
role: symbol
role_heading: Instance Method
path: "coremedia/cmtag-swift.class/value(onlyifmatching:)"
---

# value(onlyIfMatching:)

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

## Declaration

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

## Parameters

- `category`: The category to check if the tag contains.

## Return Value

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

## See Also

### Inspecting Tags

- [rawCategory](coremedia/cmtag-swift.class/rawcategory-swift.property.md)
- [rawTagValue](coremedia/cmtag-swift.class/rawtagvalue.md)
