iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK
by Kyle Richter, Joe Keeley
Predicate Song Matching
Often, an app won’t just want to play random tracks and will want to perform a more advanced search. This is done using predicates. The following example uses a predicate to find music library items that have an artist property equal to "Bob Dylan", as shown in Figure 6.3. This method functions very similarly to the previous random song example, except that addFilterPredicate is used to add the filter to the MPMediaQuery. In addition, the results are not filtered down to a single item, and the player is passed an array of all the matching songs. For a complete list of available predicate constants, see the second column of Table 6.1 in the “Handling State Changes” section. Multiple predicates can be used with supplemental ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access