<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.9.0 - 10.15.0"
  ],
  "documentType" : "symbol",
  "framework" : "MediaLibrary",
  "identifier" : "/documentation/MediaLibrary/MLMediaSource/mediaObject(forIdentifier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Media Library"
    ],
    "preciseIdentifier" : "c:objc(cs)MLMediaSource(im)mediaObjectForIdentifier:"
  },
  "title" : "mediaObject(forIdentifier:)"
}
-->

# mediaObject(forIdentifier:)

Returns the media object with the specified identifier.

```
func mediaObject(forIdentifier mediaObjectIdentifier: String) -> MLMediaObject?
```

## Parameters

`mediaObjectIdentifier`

The media object identifier to search for in the media source.

## Discussion

The media source must have finished loading before this method returns valid data. Specifically, the root media group must be available before the lookup methods will succeed. Otherwise, the return value is undefined.

---

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)