Combining your predicates this way makes it like "AND" relationship. It means that you are querying for a song that has title, album and name all are matching the search text.
To achive what you are trying to do, you should run 3 queries and combining the results in a proper way.
If you run:
MPMediaPropertyPredicate *artistPredicate =
[MPMediaPropertyPredicate predicateWithValue:searchText
forProperty:MPMediaItemPropertyArtist
comparisonType:MPMediaPredicateComparisonContains];
NSSet *predicates = [NSSet setWithObjects: artistPredicate, nil];
MPMediaQuery *songsQuery = [[MPMediaQuery alloc] initWithFilterPredicates: predicates];
NSLog(@"%@", [songsQuery items]);
This will return you with artists matching your search.
The same you should do for songs and albums.
If you this this is slow, you may retrieve all the media at once and filter it manually:
MPMediaQuery *everything = [[MPMediaQuery alloc] init];
NSLog(@"Logging items from a generic query...");
NSArray *itemsFromGenericQuery = [everything items];
for (MPMediaItem *song in itemsFromGenericQuery) {
NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle];
/* Filter found songs here manually */
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…