<!--
{
  "availability" : [
    "iOS: 4.2.0 -",
    "iPadOS: 4.2.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPMediaItem/persistentIDProperty(forGroupingType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Media Player",
      "MediaPlayer"
    ],
    "preciseIdentifier" : "c:objc(cs)MPMediaItem(cm)persistentIDPropertyForGroupingType:"
  },
  "title" : "persistentIDProperty(forGroupingType:)"
}
-->

# persistentIDProperty(forGroupingType:)

Obtains the persistent identifier key for a specified grouping type.

```
class func persistentIDProperty(forGroupingType groupingType: MPMediaGrouping) -> String
```

## Parameters

`groupingType`

The grouping type that you want the persistent identifier key for.

## Return Value

The identifier for the group type.

## Discussion

Use this convenience method to obtain the key for a specific persistent identifier based on a grouping type. You can use that key, in turn, to obtain the value of a specific persistent ID of a media item, such as album title or artist name. Using this method simplifies such tasks as drilling down from an artist, to albums by that artist, to a specific album.

For example, the following statement returns the persistent identifier key for the album grouping type:

```objc
NSString *albumIDKey = [MPMediaItem persistentIDPropertyForGroupingType: MPMediaGroupingAlbum];
```

You could then obtain the specific persistent ID that you want by using the [`value(forProperty:)`](/documentation/MediaPlayer/MPMediaEntity/value(forProperty:)) method. [`MPMediaGrouping`](/documentation/MediaPlayer/MPMediaGrouping) describes grouping keys.

---

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)