<!--
{
  "documentType" : "article",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/cmtagcollection",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "CMTagCollection"
}
-->

# CMTagCollection

Objective-C types and interfaces for working with Core Media tag collections.

## Topics

### Creating Collections

[`extern OSStatus CMTagCollectionCreate(CFAllocatorRef allocator, const CMTag *tags, CMItemCount tagCount, CMTagCollectionRef*newCollectionOut);`](/documentation/CoreMedia/CMTagCollectionCreate)

Creates a new tag collection from an existing C-style array of tags.

[`extern OSStatus CMTagCollectionCreateMutable(CFAllocatorRef allocator, CFIndex capacity, CMMutableTagCollectionRef*newMutableCollectionOut);`](/documentation/CoreMedia/CMTagCollectionCreateMutable)

Creates a new, mutable, empty tag collection.

[`extern OSStatus CMTagCollectionCreateFromData(CFDataRef data, CFAllocatorRef allocator, CMTagCollectionRef*newCollectionOut);`](/documentation/CoreMedia/CMTagCollectionCreateFromData)

Creates a new tag collection from an existing Core Foundation data instance.

[`extern OSStatus CMTagCollectionCreateFromDictionary(CFDictionaryRef dict, CFAllocatorRef allocator, CMTagCollectionRef*newCollectionOut);`](/documentation/CoreMedia/CMTagCollectionCreateFromDictionary)

Creates a new tag collection from an existing Core Foundation dictionary.

### Converting to Other Types

[`extern CFDataRefCMTagCollectionCopyAsData(CMTagCollectionRef tagCollection, CFAllocatorRef allocator);`](/documentation/CoreMedia/CMTagCollectionCopyAsData)

Creates a new Core Foundation data instance from a tag collection.

[`extern CFDictionaryRefCMTagCollectionCopyAsDictionary(CMTagCollectionRef tagCollection, CFAllocatorRef allocator);`](/documentation/CoreMedia/CMTagCollectionCopyAsDictionary)

Creates a new Core Foundation dictionary from a tag collection.

### Inspecting Collections

[`extern CMItemCount CMTagCollectionGetCount(CMTagCollectionRef tagCollection);`](/documentation/CoreMedia/CMTagCollectionGetCount)

Gets the number of tags in a tag collection.

[`extern CMItemCount CMTagCollectionCountTagsWithFilterFunction(CMTagCollectionRef tagCollection, CMTagCollectionTagFilterFunction filterApplier, void *context);`](/documentation/CoreMedia/CMTagCollectionCountTagsWithFilterFunction)

Counts the number of tags in a collection matching an evaluation function.

[`extern Boolean CMTagCollectionIsEmpty(CMTagCollectionRef tagCollection);`](/documentation/CoreMedia/CMTagCollectionIsEmpty)

Checks if a tag collection has no elements.

[`extern OSStatus CMTagCollectionGetTags(CMTagCollectionRef tagCollection, CMTag *tagBuffer, CMItemCount tagBufferCount, CMItemCount *numberOfTagsCopied);`](/documentation/CoreMedia/CMTagCollectionGetTags)

Retrieves an arbitrary number of tags from the collection.

[`extern OSStatus CMTagCollectionGetTagsWithCategory(CMTagCollectionRef tagCollection, CMTagCategory category, CMTag *tagBuffer, CMItemCount tagBufferCount, CMItemCount *numberOfTagsCopied);`](/documentation/CoreMedia/CMTagCollectionGetTagsWithCategory)

Retrieves a C-style array of tags with a given category from a tag collection.

[`extern OSStatus CMTagCollectionGetTagsWithFilterFunction(CMTagCollectionRef tagCollection, CMTag *tagBuffer, CMItemCount tagBufferCount, CMItemCount *numberOfTagsCopied, CMTagCollectionTagFilterFunction filter, void *context);`](/documentation/CoreMedia/CMTagCollectionGetTagsWithFilterFunction)

Gets all tags in a collection matching an evaluation function.

[`extern Boolean CMTagCollectionContainsCategory(CMTagCollectionRef tagCollection, CMTagCategory category);`](/documentation/CoreMedia/CMTagCollectionContainsCategory)

Determines if a tag collection contains tags for a given category.

[`extern CMItemCount CMTagCollectionGetCountOfCategory(CMTagCollectionRef tagCollection, CMTagCategory category);`](/documentation/CoreMedia/CMTagCollectionGetCountOfCategory)

Retrieves the number of tags in the collection matching a given category.

[`extern Boolean CMTagCollectionContainsTag(CMTagCollectionRef tagCollection, CMTag tag);`](/documentation/CoreMedia/CMTagCollectionContainsTag)

Determines if a tag collection contains a specific tag.

[`extern Boolean CMTagCollectionContainsSpecifiedTags(CMTagCollectionRef tagCollection, const CMTag *containedTags, CMItemCount containedTagCount);`](/documentation/CoreMedia/CMTagCollectionContainsSpecifiedTags)

Determines if a tag collection contains a subset of tags.

[`extern Boolean CMTagCollectionContainsTagsOfCollection(CMTagCollectionRef tagCollection, CMTagCollectionRef containedTagCollection);`](/documentation/CoreMedia/CMTagCollectionContainsTagsOfCollection)

Determines if one collection of tags contains every tag from another collection.

[`extern CFStringRefCMTagCollectionCopyDescription(CFAllocatorRef allocator, CMTagCollectionRef tagCollection);`](/documentation/CoreMedia/CMTagCollectionCopyDescription)

Retrieves a copy of the tag collection’s description.

[`extern CFTypeID CMTagCollectionGetTypeID();`](/documentation/CoreMedia/CMTagCollectionGetTypeID)

Retrieves the internal type ID for tag collections.

### Modifying Collection Tags

[`extern OSStatus CMTagCollectionAddTag(CMMutableTagCollectionRef tagCollection, CMTag tagToAdd);`](/documentation/CoreMedia/CMTagCollectionAddTag)

Adds a new tag to an existing collection.

[`extern OSStatus CMTagCollectionAddTagsFromArray(CMMutableTagCollectionRef tagCollection, CMTag *tags, CMItemCount tagCount);`](/documentation/CoreMedia/CMTagCollectionAddTagsFromArray)

Adds the tags contained in a C-style array to a tag collection.

[`extern OSStatus CMTagCollectionAddTagsFromCollection(CMMutableTagCollectionRef tagCollection, CMTagCollectionRef collectionWithTagsToAdd);`](/documentation/CoreMedia/CMTagCollectionAddTagsFromCollection)

Add the tags contained in one collection to another.

[`extern OSStatus CMTagCollectionRemoveAllTags(CMMutableTagCollectionRef tagCollection);`](/documentation/CoreMedia/CMTagCollectionRemoveAllTags)

Removes all tags from a collection.

[`extern OSStatus CMTagCollectionRemoveAllTagsOfCategory(CMMutableTagCollectionRef tagCollection, CMTagCategory category);`](/documentation/CoreMedia/CMTagCollectionRemoveAllTagsOfCategory)

Removes all tags of a given category from a collection.

[`extern OSStatus CMTagCollectionRemoveTag(CMMutableTagCollectionRef tagCollection, CMTag tagToRemove);`](/documentation/CoreMedia/CMTagCollectionRemoveTag)

Removes a specific tag from a collection.

### Deriving New Collections

[`extern OSStatus CMTagCollectionCreateCopy(CMTagCollectionRef tagCollection, CFAllocatorRef allocator, CMTagCollectionRef*newCollectionCopyOut);`](/documentation/CoreMedia/CMTagCollectionCreateCopy)

Creates a copy of a tag collection.

[`extern OSStatus CMTagCollectionCreateMutableCopy(CMTagCollectionRef tagCollection, CFAllocatorRef allocator, CMMutableTagCollectionRef*newMutableCollectionCopyOut);`](/documentation/CoreMedia/CMTagCollectionCreateMutableCopy)

Creates a new mutable copy from an existing tag collection.

[`extern OSStatus CMTagCollectionCopyTagsOfCategories(CFAllocatorRef allocator, CMTagCollectionRef tagCollection, const CMTagCategory *categories, CMItemCount categoriesCount, CMTagCollectionRef*collectionWithTagsOfCategories);`](/documentation/CoreMedia/CMTagCollectionCopyTagsOfCategories)

Creates a new tag collection from an existing collection, copying all tags which match a list of categories.

[`extern OSStatus CMTagCollectionCreateUnion(CMTagCollectionRef tagCollection1, CMTagCollectionRef tagCollection2, CMTagCollectionRef*tagCollectionOut);`](/documentation/CoreMedia/CMTagCollectionCreateUnion)

Creates a new tag collection containing all tags from two collections without duplicates.

[`extern OSStatus CMTagCollectionCreateDifference(CMTagCollectionRef tagCollectionMinuend, CMTagCollectionRef tagCollectionSubtrahend, CMTagCollectionRef*tagCollectionOut);`](/documentation/CoreMedia/CMTagCollectionCreateDifference)

Creates a new tag collection with the difference of two existing collections.

[`extern OSStatus CMTagCollectionCreateExclusiveOr(CMTagCollectionRef tagCollection1, CMTagCollectionRef tagCollection2, CMTagCollectionRef*tagCollectionOut);`](/documentation/CoreMedia/CMTagCollectionCreateExclusiveOr)

Creates a new tag collection from two existing tag collections, copying elements which are in one collection or the other, but not both.

[`extern OSStatus CMTagCollectionCreateIntersection(CMTagCollectionRef tagCollection1, CMTagCollectionRef tagCollection2, CMTagCollectionRef*tagCollectionOut);`](/documentation/CoreMedia/CMTagCollectionCreateIntersection)

Creates a new tag collection containing only the tags from two existing collections which match.

### Iterating Over Tags

[`extern void CMTagCollectionApply(CMTagCollectionRef tagCollection, CMTagCollectionApplierFunction applier, void *context);`](/documentation/CoreMedia/CMTagCollectionApply)

Applies a function to all tags in a collection.

[`extern CMTag CMTagCollectionApplyUntil(CMTagCollectionRef tagCollection, CMTagCollectionTagFilterFunction applier, void *context);`](/documentation/CoreMedia/CMTagCollectionApplyUntil)

Applies a Boolean function to tags in a collection, stopping when it returns true.

### Types

[`typedef const struct OpaqueCMTagCollection * CMTagCollectionRef;`](/documentation/CoreMedia/CMTagCollectionRef)

A reference to a tag collection.

[`typedef struct OpaqueCMTagCollection * CMMutableTagCollectionRef;`](/documentation/CoreMedia/CMMutableTagCollectionRef)

A mutable reference to a tag collection.

[`typedef void (*)(struct CMTag, void *) CMTagCollectionApplierFunction;`](/documentation/CoreMedia/CMTagCollectionApplierFunction)

A type for function application over elements of a tag collection.

[`typedef unsigned char (*)(struct CMTag, void *) CMTagCollectionTagFilterFunction;`](/documentation/CoreMedia/CMTagCollectionTagFilterFunction)

A type for filtering of tag collections.

### Constants

[`extern CFStringRef const kCMTagCollectionTagsArrayKey;`](/documentation/CoreMedia/kCMTagCollectionTagsArrayKey)

A dictionary key for assigning tag collections to.

### Errors

[`enum CMTagCollectionError : OSStatus;`](/documentation/CoreMedia/CMTagCollectionError)

Error codes returned by Core Media when working with tag collections.



---

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)