---
title: "init(propertiesOfMetadataItem:valueLoadingHandler:)"
framework: avfoundation
role: symbol
role_heading: Initializer
path: "avfoundation/avmetadataitem/init(propertiesofmetadataitem:valueloadinghandler:)"
---

# init(propertiesOfMetadataItem:valueLoadingHandler:)

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

## Declaration

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

## Parameters

- `metadataItem`: The metadata item that provides the doc://com.apple.avfoundation/documentation/AVFoundation/AVMetadataItem/identifier, doc://com.apple.avfoundation/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

Return Value A newly created instance of AVMetadataItem.

## Discussion

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 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:). If loading of the value fails, provide an instance an error object that describes the failure by calling respond(error:). // 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.

## See Also

### Creating a metadata item

- [AVMetadataItemValueRequest](avfoundation/avmetadataitemvaluerequest.md)
