<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "swift: -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVMetadataItem/init(propertiesOfMetadataItem:valueLoadingHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVMetadataItem(cm)metadataItemWithPropertiesOfMetadataItem:valueLoadingHandler:::SYNTHESIZED::c:objc(cs)AVMetadataItem"
  },
  "title" : "init(propertiesOfMetadataItem:valueLoadingHandler:)"
}
-->

# init(propertiesOfMetadataItem:valueLoadingHandler:)

Creates a metadata item whose value loads on an on-demand basis only.

```
init(propertiesOfMetadataItem metadataItem: AVMetadataItem, valueLoadingHandler handler: @escaping @Sendable (AVMetadataItemValueRequest) -> Void)
```

## Parameters

`metadataItem`

The metadata item that provides the [`identifier`](/documentation/AVFoundation/AVMetadataItem/identifier), [`extendedLanguageTag`](/documentation/AVFoundation/AVMetadataItem/extendedLanguageTag), and other property values that you want the newly created metadata item to share. The system ignores the value of this template metadata item.

`handler`

A callback the system invokes to load the value for the metadata item.

## Return Value

A newly created instance of [`AVMetadataItem`](/documentation/AVFoundation/AVMetadataItem).

## Discussion

Use this method to create metadata items for optional display purposes. For example, a metadata item that provides a large image, should only load the image when the system requests it.

When you load the [`value`](/documentation/AVFoundation/AVPartialAsyncProperty/value) of a metadata item you created with this initializer, the closure you provide as the value loading handler executes on an arbitrary dispatch queue, off the main thread. The handler can perform I/O and other necessary operations to obtain the value. If loading of the value succeeds, provide the value by calling [`respond(value:)`](/documentation/AVFoundation/AVMetadataItemValueRequest/respond(value:)). If loading of the value fails, provide an instance an error object that describes the failure by calling [`respond(error:)`](/documentation/AVFoundation/AVMetadataItemValueRequest/respond(error:)).

```swift
// A template metadata item that provides supporting data.
let templateItem = AVMetadataItem()
let artworkItem = AVMetadataItem(propertiesOf: templateItem) { request in
    if let image = UIImage(named: "large_artwork"), let data = image.pngData() {
        request.respond(value: NSData(data: data))
    } else {
        request.respond(error: AppError.imageLoadingError)
    }
}
```

> Note:
> Don’t use this method to create metadata items whose values you need immediately, such as those you create for immediate display or serialization.

---

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)