Search code examples
iosobjective-cmpmediaitemmpmediaquery

fastest way to get MPMediaItem with no album data


Im looking for the faster way to grab all songs from my iOS music library that do not belong to an album.

I know essentially I can traverse through all the tracks and check for an album title. But I was looking a better way, maybe use a predicate of something like this...

[[MPMediaQuery songsQuery] addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:@"Unknown Album" forProperty:MPMediaItemPropertyAlbumTitle]];

any help is much appreciated


Solution

  • fastest way I found is by settings a predicate on the [MPMediaQuery songsQuery]

    [[MPMediaQuery songsQuery] addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:@"0" forProperty:MPMediaItemPropertyAlbumPersistentID]];