<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MusicKit",
  "identifier" : "/documentation/MusicKit/MusicItem/with(_:preferredSource:)-2hn42",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MusicKit"
    ],
    "preciseIdentifier" : "s:8MusicKit0A4ItemPA2A0A17PropertyContainerRzSeRzrlE4with_15preferredSourcexAA07Partiala5AsyncD0CyxGd_AA0adH0OtYaKF"
  },
  "title" : "with(_:preferredSource:)"
}
-->

# with(_:preferredSource:)

Loads a new instance of the music item that includes
the specified properties.

```
func with(_ properties: PartialMusicAsyncProperty<Self>..., preferredSource: MusicPropertySource) async throws -> Self
```

## Discussion

This asynchronous method fetches a more complete representation
of the receiver, loading the contents for each property you request
from either the Apple Music catalog or the user’s library, depending
on the preferred source as well the availability of the content in those
respective data sources.

For example, if you want to load the
[`tracks`](/documentation/MusicKit/PartialMusicProperty/tracks-9mk2l) relationship for
an [`Album`](/documentation/MusicKit/Album), as found in the user’s library, as well as other
associations of content that only live in the Apple Music catalog,
like the [`recordLabels`](/documentation/MusicKit/PartialMusicProperty/recordLabels) and
[`relatedAlbums`](/documentation/MusicKit/PartialMusicProperty/relatedAlbums) associations,
you can use this code:

```
let album: Album = …
let detailedAlbum = try await album.with(
    .tracks,
    .recordLabels,
    .relatedAlbums, 
    preferredSource: .library
)
```

Here, because the [`tracks`](/documentation/MusicKit/PartialMusicProperty/tracks-9mk2l) relationship
for an [`Album`](/documentation/MusicKit/Album) is supported in both the library and the catalog,
and because the this code specifically requests
[`MusicPropertySource.library`](/documentation/MusicKit/MusicPropertySource/library) as the preferred source,
the framework will load the tracks from the user’s library.
However, because the [`recordLabels`](/documentation/MusicKit/PartialMusicProperty/recordLabels)
and [`relatedAlbums`](/documentation/MusicKit/PartialMusicProperty/relatedAlbums) associations are only
available in the Apple Music catalog, the framework will also issue
a network request to Apple Music API to fetch those associations
of content from the catalog.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)