Reputation: 23558
I would like to add a series of predicates to an MPMediaQuery
, but I want it aggregated using OR, not AND:
MPMediaQuery *q = [MPMediaQuery songsQuery];
NSMutableArray *a = [@[] mutableCopy];
for (DFLocalMediaItem *item in self.offlineItems) {
MPMediaPropertyPredicate* p = [MPMediaPropertyPredicate predicateWithValue:item.identifier
forProperty:MPMediaItemPropertyPersistentID];
[a addObject:p];
}
NSSet *s = [NSSet setWithArray:a];
[q setFilterPredicates:s];
when I create this set, it's aggregating the above MPMediaPropertyPredicate
using AND (which won't work obviously.. since a single MPMediaItem will obviously have a single identifier)
ideas?
Upvotes: 1
Views: 403
Reputation: 332
You couldn't have such functionality due to public API. The official docs says that
When you apply more than one predicate to a query, the query combines them using the logical AND operator.
But you could construct an MPMediaItemCollection if you want from your items or you could construct from an array similar to MPMediaQuery structure that has the same methods, but has static array behind.
Upvotes: 2