I've instantiated a query to request a collection of all the playlists on my iPod Touch. The result, returned from the MPMediaQuery collections property, contains 43 items. These include all 17 of the PlayLists that the native Music app shows. However, the collection also contains 26 "playlists" that are actually albums from my iPod library. That represents some(but not all) of the albums on the iPod.
I've tried to see if there was an MPMediaPlaylist attribute that might distinguish the albums from actual playlists, to no avail. I looked at the sections of the collection to see if real playlists are kept in a separate sections from the albums, but there was only a single section. Finally, I looked to see if the albums have a PersistantID, which the documentation indicates is unique to playlists. All the items in the array have a PersistantID.
The Music app has no trouble displaying just the 17 actual playlists, so there must be something I'm missing. Here is the code used to build the query:
MPMediaQuery * myPlaylistsQuery = [ MPMediaQuery playlistsQuery ];
NSArray * playlists = [ myPlaylistsQuery collections ];
Here is a sample of the data that gets logged when the contents of the "playlists" array is interrogated:
=====================================================
List of playlists
.... There are 01 sections in the playlist collection
.... There are 43 MPMediaPlaylist objects in the playlist collection
Bach
.... Persistant ID: 17002820337772537981
Best of Simon and Garfunkel
.... Persistant ID: 2965021518813542622
Blue
.... Persistant ID: 11514004552991695558
Blues
.... Persistant ID: 14243796139384893728
.... (etc)
In the above listing, the entries "Bach", "Best of Simon and Garfunkel" and "Blue" represent albums. The entry "Blues" represents the first of the true playlists that I've defined on iTunes.
I suppose that I could compare the items returned from the playlist query against a the items in an albums query, and eliminate any matches. Is there a more straightforward solution?