I have an “songs” NSMutableArray filled with all songs on the device:
MPMediaQuery *everything = [MPMediaQuery songsQuery];
NSArray *songCollections = [everything collections];
songs = [NSMutableArray array];
for (MPMediaItemCollection *song in songCollections) {
MPMediaItem *representativeItem = [song representativeItem];
[songs addObject:representativeItem];
}
Is there a way to sort them by album? I have noticed that adding
[everything setGroupingType:MPMediaGroupingAlbum];
produces a strange result (it’s just pushing in the array the first song for each album)
Thanks in advance
You can fetch the albums and then iterate through them to populate a song array, resulting in the songs sorted with respect to the albums:
Hope this helps