MPMediaPropertyPredicate Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/MediaPlayer.framework
Availability
Available in iOS 3.0 and later.
Companion guide
Declared in
MPMediaQuery.h
Related sample code

Overview

Use one or more MPMediaPropertyPredicate objects, or media property predicates, to define the filter in a media query to retrieve a subset of media items from the iPod library. A predicate in this context is a statement of a logical condition that you want to test each media item against. Those items that satisfy the condition are retrieved in the query result.

You define iPod library queries, and retrieve query results, using the MPMediaQuery class, described in MPMediaQuery Class Reference. The media items and media item collections that you retrieve with a query are described in MPMediaItem Class Reference and MPMediaItemCollection Class Reference.

Tasks

Creating Media Property Predicates

Examining Media Property Predicates

Properties

comparisonType

The type of matching comparison that the media property predicate performs when you invoke a query.

@property (nonatomic, readonly) MPMediaPredicateComparison comparisonType;
Discussion

For comparison types, see “Media Property Predicate Comparison Types.”

Availability
  • Available in iOS 3.0 and later.
Declared In
MPMediaQuery.h

property

The property that the media property predicate uses when you invoke a query.

@property (nonatomic, readonly, copy) NSString *property;
Availability
  • Available in iOS 3.0 and later.
Declared In
MPMediaQuery.h

value

The value that the media property predicate matches against when you invoke a query.

@property (nonatomic, readonly) id value;
Availability
  • Available in iOS 3.0 and later.
Declared In
MPMediaQuery.h

Class Methods

predicateWithValue:forProperty:

Creates a media property predicate with the default comparison type.

+ (MPMediaPropertyPredicate *)predicateWithValue:(id)value forProperty:(NSString *)property
Parameters
predicateWithValue:

The property value that you want to match when you query the iPod library. For example, if you specify the MPMediaItemPropertyArtist constant in the forProperty parameter, in this parameter you supply a string containing the artist name.

forProperty:

A so-called filterable property—one that can be used to build a media property predicate. See General Media Item Property Keys and Podcast Item Property Keys in MPMediaItem Class Reference.

Return Value

A media property predicate.

Discussion

This is a convenience method that uses the default logical comparison type of MPMediaPredicateComparisonEqualTo.

Availability
  • Available in iOS 3.0 and later.
Related Sample Code
Declared In
MPMediaQuery.h

predicateWithValue:forProperty:comparisonType:

Creates a media property predicate with a specified comparison type.

+ (MPMediaPropertyPredicate *)predicateWithValue:(id)value forProperty:(NSString *)property comparisonType:(MPMediaPredicateComparison)comparisonType
Parameters
predicateWithValue:

The property value that you want to match when you query the iPod library. For example, if you specify the MPMediaItemPropertyArtist constant in the forProperty parameter, in this parameter you supply a string containing the artist name.

forProperty:

A so-called filterable property—one that can be used to build a media property predicate. See General Media Item Property Keys and Podcast Item Property Keys in MPMediaItem Class Reference.

comparisonType:

The logical comparison type for the predicate. See “Media Property Predicate Comparison Types.”

Return Value

A media property predicate.

Availability
  • Available in iOS 3.0 and later.
Declared In
MPMediaQuery.h

Constants

Media Property Predicate Comparison Types

Logical comparison types for media queries.

enum {
   MPMediaPredicateComparisonEqualTo,
   MPMediaPredicateComparisonContains
};
typedef NSInteger MPMediaPredicateComparison;
Constants
MPMediaPredicateComparisonEqualTo

Matches when a media item’s value for a given property is equal to the value in the media property predicate.

Available in iOS 3.0 and later.

Declared in MPMediaQuery.h.

MPMediaPredicateComparisonContains

Matches when a media item’s value for a given property is contained in the value of the media property predicate.

Available in iOS 3.0 and later.

Declared in MPMediaQuery.h.