Enumeration

MPMediaGrouping

Keys used to configure a media query.

Declaration

typedef enum MPMediaGrouping : NSInteger {
    ...
} MPMediaGrouping;

Overview

The following code snippet shows how to apply a grouping key:

MPMediaQuery *everything = [[MPMediaQuery alloc] init];
[everything setGroupingType: MPMediaGroupingAlbum];
NSArray *collections = [everything collections];

After running these code lines, the collections array contains all the matched media items grouped and sorted according to album name.

To obtain a sorted list of songs, configure a media query with the MPMediaGroupingTitle key, or take advantage of the title key being the default for a media query. In either case, each obtained media item is, in effect, its own collection.

Collections sort according to the same rules used by iTunes on the desktop. This includes respecting the primary system language chosen by the user. Leading articles, including “A,” “An,” and “The” when using English, or “L’,” “La,” and “Le” when using French, are ignored during sorting. If you need precise control over sorting, implement it in your application.

Topics

Media Query Keys

MPMediaGroupingTitle

Groups and sorts media item collections by title. For songs, for example, the title is the song name. This is the default grouping key.

MPMediaGroupingAlbum

Groups and sorts media item collections by album, and sorts songs within an album by track order.

MPMediaGroupingArtist

Groups and sorts media item collections by performing artist.

MPMediaGroupingAlbumArtist

Groups and sorts media item collections by album artist (the primary performing artist for an album as a whole).

MPMediaGroupingComposer

Groups and sorts media item collections by composer.

MPMediaGroupingGenre

Groups and sorts media item collections by musical or film genre.

MPMediaGroupingPlaylist

Groups and sorts media item collections by playlist.

MPMediaGroupingPodcastTitle

Groups and sorts media item collections by podcast title.

See Also

Configuring Media Queries

filterPredicates

The media property predicates of the media query.

- addFilterPredicate:

Adds a media property predicate to a query.

- removeFilterPredicate:

Removes a filter predicate from a query.

groupingType

The grouping for collections retrieved with the media query.

itemSections

An array representing the section grouping of the query's specified media items.

collectionSections

An array representing the section grouping of the query's specified media item collections.