iOS Developer Library

Developer

MediaPlayer Framework Reference MPMediaItemCollection Class Reference

Options
Deployment Target:

On This Page
Language:

MPMediaItemCollection

A media item collection is a sorted set of media items (instances of the MPMediaItem class) from the iPod library. Typically, you use this class by requesting an array of collections from a media query by way of its collections property. Media queries are described in MPMediaQuery Class Reference. More...

Inheritance


Import Statement


import MediaPlayer @import MediaPlayer;

Availability


Available in iOS 3.0 and later.
  • Creates a media item collection by copying an array of media items.

    Declaration

    Objective-C

    + (MPMediaItemCollection *)collectionWithItems:(NSArray *)items

    Parameters

    items

    The array of media items you are assigning to the media item collection.

    Return Value

    A media item collection.

    Import Statement

    Availability

    Available in iOS 3.0 and later.

  • init(items:) initWithItems: Designated Initializer

    Initializes a media item collection with an array of media items.

    Declaration

    Swift

    init!(items items: [AnyObject]!)

    Objective-C

    - (instancetype)initWithItems:(NSArray *)items

    Parameters

    items

    The array of items you are assigning to the media item collection.

    Import Statement

    import MediaPlayer

    Availability

    Available in iOS 3.0 and later.

  • items items Property

    The media items in a media item collection.

    Declaration

    Swift

    var items: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *items

    Import Statement

    import MediaPlayer

    Availability

    Available in iOS 3.0 and later.

  • A media item whose properties are representative of the other media items in a collection.

    Declaration

    Swift

    var representativeItem: MPMediaItem! { get }

    Objective-C

    @property(nonatomic, readonly) MPMediaItem *representativeItem

    Discussion

    The media items in a collection typically share common property values, owing to how the collection was built. For example, if you build a collection based on a predicate that uses the MPMediaItemPropertyArtist property, all items in the collection share the same artist name. You can use the representativeItem property to efficiently obtain values for such common properties—often more efficiently than fetching an item from the items array.

    Import Statement

    import MediaPlayer

    Availability

    Available in iOS 3.0 and later.

  • count count Property

    The number of media items in a collection.

    Declaration

    Swift

    var count: Int { get }

    Objective-C

    @property(nonatomic, readonly) NSUInteger count

    Discussion

    In some cases, using this property is more efficient than fetching the items array and asking for the count.

    Import Statement

    import MediaPlayer

    Availability

    Available in iOS 3.0 and later.

  • The types of the media items in a collection.

    Declaration

    Swift

    var mediaTypes: MPMediaType { get }

    Objective-C

    @property(nonatomic, readonly) MPMediaType mediaTypes

    Discussion

    The media item types are listed in the Media Item Type Flags enumeration in MPMediaItem Class Reference.

    Import Statement

    import MediaPlayer

    Availability

    Available in iOS 3.0 and later.