Instance Method

addItem(withProductID:completionHandler:)

Adds the designated item to the user's music library.

Declaration

func addItem(withProductID productID: String, completionHandler: (([MPMediaEntity], Error?) -> Void)? = nil)

Parameters

productID

The product identifier for the media item to be added.

completionHandler

A block called after the media item has been added.

entities

An array containing the media items added to the user's music library.

error

If an error occurred, this parameter holds the error object that explains the error. Otherwise, the value of this parameter is nil.

Discussion

Use this method to add media items to a user's music library. Use the Apple Music API Reference to search for content contained in the iTunes, App, Book, and Mac App stores.