collections
An array of media item collections whose contained items match the query’s media property predicate.
Declaration
var collections: [MPMediaItemCollection]? { get }Discussion
The system groups and sorts the returned array of collections by the groupingType of the media query. The following code listing demonstrates how to use this property:
Each element of the collections array now contains a media item collection. Each collection contains the media items from the library by a particular artist. The system sorts elements of the array by the artist name.
For the available grouping types, see MPMediaGrouping.