---
title: "MDQueryGetIndexOfResult(_:_:)"
framework: coreservices
role: symbol
role_heading: Function
path: coreservices/1413093-mdquerygetindexofresult
---

# MDQueryGetIndexOfResult(_:_:)

Returns the current index of the given result.

## Declaration

```swift
func MDQueryGetIndexOfResult(_ query: MDQuery!, _ result: UnsafeRawPointer!) -> CFIndex
```

## Parameters

- `query`: The query.
- `result`: The result object to search for. If a custom create-result function has been set and this parameter is not a valid result object that the provided callbacks can handle, the behavior is undefined. If a custom create-result function has not been set this parameter must be a valid MDItemRef.

## Return Value

Return Value The index of the given result, or kCFNotFound if the value is not one of the query's existing results. If you provided a custom result creation function result, the result will be objects created by that function.

## Discussion

Discussion If a result-create function has been set, and the equal callback is non-NULL, it will be used to test the query's results against the candidate result.  Note that the index of a result can change over time if the query allows live-updates.

## See Also

### Getting Query Result Values

- [MDQueryCopyValuesOfAttribute(_:_:)](coreservices/1413105-mdquerycopyvaluesofattribute.md)
- [MDQueryGetAttributeValueOfResultAtIndex(_:_:_:)](coreservices/1413046-mdquerygetattributevalueofresult.md)
- [MDQueryGetCountOfResultsWithAttributeValue(_:_:_:)](coreservices/1413009-mdquerygetcountofresultswithattr.md)
- [MDQueryGetResultAtIndex(_:_:)](coreservices/1413055-mdquerygetresultatindex.md)
- [MDQueryGetResultCount(_:)](coreservices/1413008-mdquerygetresultcount.md)
- [MDQuerySetSortComparatorBlock(_:_:)](coreservices/1413021-mdquerysetsortcomparatorblock.md)
