---
title: "value(ofAttribute:forResultAt:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsmetadataquery/value(ofattribute:forresultat:)"
---

# value(ofAttribute:forResultAt:)

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

## Declaration

```swift
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 doc://com.apple.foundation/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

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

## See Also

### Getting query results

- [results](foundation/nsmetadataquery/results.md)
- [resultCount](foundation/nsmetadataquery/resultcount.md)
- [result(at:)](foundation/nsmetadataquery/result(at:).md)
- [index(ofResult:)](foundation/nsmetadataquery/index(ofresult:).md)
- [groupedResults](foundation/nsmetadataquery/groupedresults.md)
- [NSMetadataQueryResultGroup](foundation/nsmetadataqueryresultgroup.md)
- [enumerateResults(_:)](foundation/nsmetadataquery/enumerateresults(_:).md)
- [enumerateResults(options:using:)](foundation/nsmetadataquery/enumerateresults(options:using:).md)
- [valueLists](foundation/nsmetadataquery/valuelists.md)
- [NSMetadataQueryAttributeValueTuple](foundation/nsmetadataqueryattributevaluetuple.md)
- [enableUpdates()](foundation/nsmetadataquery/enableupdates().md)
- [disableUpdates()](foundation/nsmetadataquery/disableupdates().md)
- [operationQueue](foundation/nsmetadataquery/operationqueue.md)
