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 ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.