This code:
MPMediaQuery *query = [MPMediaQuery artistsQuery];
NSArray *songsByArtist = [query collections];
for( MPMediaItemCollection *c in songsByArtist ) {
NSLog(@"artist %@ has %u songs",[[c representativeItem] valueForProperty:MPMediaItemPropertyArtist], [[c items]count]);
}
works as expected. But this code:
MPMediaQuery *query = [MPMediaQuery artistsQuery];
NSArray *songsByArtist = [query collections];
for( MPMediaItemCollection *c in songsByArtist ) {
NSLog(@"artist %@ has %u songs",[[c representativeItem] valueForProperty:MPMediaItemPropertyArtist], [c count]);
}
always prints "1" for the number of songs. Can anyone else confirm this issue? It seems like a bug when looking at the documentation.
Looks like you're counting the collections in that query rather than the songs inside of it.