views:

81

answers:

0

Hello,

What is the best way to see if a song exists in the iPod library? I am currently doing the following:

    MPMediaQuery *query = [[MPMediaQuery alloc] init];

[query addFilterPredicate: [MPMediaPropertyPredicate
                            predicateWithValue: artist
                            forProperty: MPMediaItemPropertyArtist]];
[query addFilterPredicate: [MPMediaPropertyPredicate
                            predicateWithValue: album
                            forProperty: MPMediaItemPropertyAlbumTitle]];
[query addFilterPredicate: [MPMediaPropertyPredicate
                            predicateWithValue: song
                            forProperty: MPMediaItemPropertyTitle]];
if([[query collections] count] > 0)
    NSLog(@"Song exists");

Is that the most efficient way? I could be doing thousand of comparisons with this method, so I'd like it to be as fast and efficient as possible.

Thank you, Justin