这段代码:
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]);
}
按预期工作。但是这段代码:
MPMediaQuery *query = [MPMediaQuery artistsQuery];
NSArray *songsByArtist = [query collections];
for( MPMediaItemCollection *c in songsByArtist ) {
NSLog(@"artist %@ has %u songs",[[c representativeItem] valueForProperty:MPMediaItemPropertyArtist], [c count]);
}
总是为歌曲的数量打印“1”。其他人可以确认这个问题吗?查看文档时,这似乎是一个错误。