I'm trying to access the user’s local music library using MPMediaQuery
to sort the results in the following manner:
Artist A (sorted alphabetically) > All of Artist A's albums, sorted alphabetically
Artist B (sorted alphabetically) > All of Artist B's albums, sorted alphabetically
Artist C (sorted alphabetically) > All of Artist C's albums, sorted alphabetically
...
My query is structured thusly:
MPMediaQuery *albumsQuery = [MPMediaQuery albumsQuery];
albumsQuery.groupingType = MPMediaGroupingAlbumArtist;
But the issue is that while the aforementioned mostly works, only first album per given artist is returned. That is, only one of Alt-J’s albums is returned, not the two that exist in the library.
Why is that? And how can I structure my query to return the desired result?
EDIT: This is how I’m accessing the albumsQuery:
AlbumCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellID forIndexPath:indexPath];
MPMediaItemCollection *collection = [_items objectAtIndex:indexPath.row];
MPMediaItem *cellItem = [collection representativeItem];
Where _items
is an NSArray that contains the MPMediaQuery
’s result.