Class

MLMediaGroup

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.

Declaration

class MLMediaGroup : NSObject

Overview

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

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

Topics

Identifying the Group

var identifier: String

An identifier for the media group.

var typeIdentifier: String

An identifier for the media group’s type.

var mediaSourceIdentifier: String

An identifier for the source that loaded the media group.

var mediaLibrary: MLMediaLibrary?

A pointer to the media library instance that loaded the media group’s source.

Accessing Group Attributes

var attributes: [String : Any]

A dictionary of attributes describing the media group.

var name: String?

The name of the media group.

var iconImage: NSImage?

The media group’s icon.

var url: URL?

The location of the media group.

var modificationDate: Date?

The date and time when the media group was last altered.

Accessing the Group Hierarchy

var parent: MLMediaGroup?

The media group’s parent group.

var childGroups: [MLMediaGroup]?

A list of child groups contained in the media group.

var mediaObjects: [MLMediaObject]?

A list of media objects in the media group.

Relationships

Inherits From

Conforms To