I'm running an MPMediaQuery to find a song in the user's iPod library, like this:
MPMediaQuery *songQuery = [MPMediaQuery songsQuery];
[songQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:track.title forProperty:MPMediaItemPropertyTitle comparisonType:MPMediaPredicateComparisonEqualTo]];
[songQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:track.album forProperty:MPMediaItemPropertyAlbumTitle comparisonType:MPMediaPredicateComparisonEqualTo]];
[songQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:track.artist forProperty:MPMediaItemPropertyArtist comparisonType:MPMediaPredicateComparisonEqualTo]];
*** CRASH HERE ***
if (songQuery.items.count > 0) {
return [songQuery.items objectAtIndex:0];
}
else {
return nil;
}
The app crashes and spits out:
'invalid value (nil) for property item_extra.title.'
Am I doing anything wrong? Is there a better way to query for a song? Thanks everyone!