<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSMetadataQueryDelegate/metadataQuery(_:replacementValueForAttribute:value:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSMetadataQueryDelegate(im)metadataQuery:replacementValueForAttribute:value:"
  },
  "title" : "metadataQuery(_:replacementValueForAttribute:value:)"
}
-->

# metadataQuery(_:replacementValueForAttribute:value:)

Returns a different value for a given attribute and value.

```
optional func metadataQuery(_ query: NSMetadataQuery, replacementValueForAttribute attrName: String, value attrValue: Any) -> Any
```

## Parameters

`query`

The query that produced the result object with `attrName`.

`attrName`

The attribute in question.

`attrValue`

The attribute value to replace.

## Return Value

Object that replaces the value of `attrName` in the result object

## Discussion

The delegate implementation of this method could convert specific query attribute values to other attribute values, for example, converting date object values to formatted strings for display.

---

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)