Mac Developer Library

Developer

MediaLibrary Framework Reference MLMediaGroup Class Reference

Options
Deployment Target:

On This Page
Language:

MLMediaGroup

Inheritance


Conforms To


Import Statement


Swift

import MediaLibrary

Objective-C

@import MediaLibrary;

Availability


Available in OS X v10.9 and later.

The MLMediaGroup class provides groupings for media objects from a single source of media, such as iTunes or Aperture. The media objects—individual files containing a piece of media such as a photo, song, or movie—are referenced by one or more groups within each media source. These groupings serve as filters, providing hierarchical structure to the collection of objects in each source.

The structure of the group hierarchy is specific to each media source, but all sources have certain commonalities. For example, every source has a single root media group, which contains all groups and objects within that source. It is the highest-level parent group in the hierarchy and each of its descendant groups contains its own subgroups and their objects. All groups have a reference to their parent within the hierarchy. A group with no descendants contains only its own objects. If a media group does not contain any objects, it is not visible in the hierarchy.

A media group has an array of attributes which can change at any point. For example, a media group may have certain attributes that describe its objects, but these attributes appear only after the objects for that group have been loaded. When any media group attribute changes, observers are notified via KVO notification. For information about handling attributes that change, see Cocoa Bindings Programming Topics.

Every media group has a unique identifier as well as a type identifier. In certain cases, multiple groups within a source can have the same type identifier. For descriptions of group type identifiers, see Media Library Constants Reference.

All MLMediaGroup properties are read-only, so this information can be accessed but not altered.

  • An identifier for the media group. (read-only)

    Declaration

    Swift

    var identifier: String! { get }

    Objective-C

    @property(readonly, copy) NSString *identifier

    Discussion

    Each group’s identifier is unique within a media source.

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • An identifier for the media group’s type. (read-only)

    Declaration

    Swift

    var typeIdentifier: String! { get }

    Objective-C

    @property(readonly, copy) NSString *typeIdentifier

    Discussion

    Multiple groups within a media source can have the same type identifier. For descriptions of group type identifiers, see Media Library Constants Reference.

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • An identifier for the source that loaded the media group. (read-only)

    Declaration

    Swift

    var mediaSourceIdentifier: String! { get }

    Objective-C

    @property(readonly, copy) NSString *mediaSourceIdentifier

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • A pointer to the media library instance that loaded the media group’s source. (read-only)

    Declaration

    Swift

    unowned(unsafe) var mediaLibrary: MLMediaLibrary! { get }

    Objective-C

    @property(readonly, assign) MLMediaLibrary *mediaLibrary

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • A dictionary of attributes describing the media group. (read-only)

    Declaration

    Swift

    var attributes: [NSObject : AnyObject]! { get }

    Objective-C

    @property(readonly, copy) NSDictionary *attributes

    Discussion

    These attributes are usually defined by the source app, such as iTunes. For example, an iTunes playlist is represented as a group. iTunes attaches attributes such as "Playlist Persistent ID" to the group in its attributes. The attribute names vary based on the media source. Attributes common to all sources are called out as separate properties.

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • name name Property

    The name of the media group. (read-only)

    Declaration

    Swift

    var name: String! { get }

    Objective-C

    @property(readonly, copy) NSString *name

    Discussion

    This string is human-readable. It is either user created (such as the name of an iTunes playlist) or already localized.

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • iconImage iconImage Property

    The media group’s icon. (read-only)

    Declaration

    Swift

    @NSCopying var iconImage: NSImage! { get }

    Objective-C

    @property(readonly, copy) NSImage *iconImage

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • URL URL Property

    The location of the media group. (read-only)

    Declaration

    Swift

    @NSCopying var URL: NSURL! { get }

    Objective-C

    @property(readonly, copy) NSURL *URL

    Discussion

    Some groups do not have a URL, in which case this returns nil. For example, a group that represents a filesystem folder on disk has a URL, but a group that represents a named face in iPhoto does not.

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • The date and time when the media group was last altered. (read-only)

    Declaration

    Swift

    @NSCopying var modificationDate: NSDate! { get }

    Objective-C

    @property(readonly, copy) NSDate *modificationDate

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • parent parent Property

    The media group’s parent group. (read-only)

    Declaration

    Swift

    unowned(unsafe) var parent: MLMediaGroup! { get }

    Objective-C

    @property(readonly, assign) MLMediaGroup *parent

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • A list of child groups contained in the media group. (read-only)

    Declaration

    Swift

    var childGroups: [AnyObject]! { get }

    Objective-C

    @property(readonly, copy) NSArray *childGroups

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • A list of media objects in the media group. (read-only)

    Declaration

    Swift

    var mediaObjects: [AnyObject]! { get }

    Objective-C

    @property(readonly, copy) NSArray *mediaObjects

    Discussion

    This accessor property is nonblocking. If there is no data yet, it returns nil and automatically triggers an internal asynchronous request. A KVO notification will be sent via the main thread when data arrives.

    Import Statement

    Objective-C

    @import MediaLibrary;

    Swift

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.