<!--
{
  "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/NSMetadataQuery/value(ofAttribute:forResultAt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMetadataQuery(im)valueOfAttribute:forResultAtIndex:"
  },
  "title" : "value(ofAttribute:forResultAt:)"
}
-->

# value(ofAttribute:forResultAt:)

Returns the value for the attribute name `attrName` at the index in the results specified by `idx`.

```
func value(ofAttribute attrName: String, forResultAt idx: Int) -> Any?
```

## Parameters

`attrName`

The attribute of the result object at `idx` being inquired about. The attribute must be specified in [`valueListAttributes`](/documentation/Foundation/NSMetadataQuery/valueListAttributes), as a sorting key in a specified sort descriptor, or as one of the grouping attributes specified set for the query.

`idx`

The index of the desired return object in the query results array.

## Return Value

Value for `attrName` in the result object at `idx` in the query result array.

---

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)