Instance Property


An array containing the query’s results.


var results: [Any] { get }


The array is a proxy object that is primarily intended for use with Cocoa bindings. While it is possible to copy the proxy array and receive a “snapshot” of the complete current query results, it is generally not recommended due to performance and memory issues. To access individual result array elements, use the resultCount and result(at:) methods.

The array supports Key-value observing, which can be used to be notified when items are added, removed, or updated in the array of results.

By default, this array contains NSMetadataItem objects, each of which represents the metadata associated with a file. However, the query’s delegate can substitute these objects with instances of a different class.

See Also

Getting Query Results

var resultCount: Int

The number of results returned by the query. (read-only)

func result(at: Int) -> Any

Returns the query result at a specific index.

func index(ofResult: Any) -> Int

Returns the index of a query result object in the receiver’s results array.

var groupedResults: [NSMetadataQueryResultGroup]

An array containing hierarchical groups of query results. (read-only)

class NSMetadataQueryResultGroup

The NSMetadataQueryResultGroup class represents a collection of grouped attribute results returned by an NSMetadataQuery object.

func enumerateResults((Any, Int, UnsafeMutablePointer<ObjCBool>) -> Void)

Enumerates the current set of results using the given block.

var valueLists: [String : [NSMetadataQueryAttributeValueTuple]]

A dictionary containing the value lists generated by the query.

class NSMetadataQueryAttributeValueTuple

The NSMetadataQueryAttributeValueTuple class represents attribute-value tuples, which are objects that contain the attribute name and value of a metadata attribute.

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

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

func enableUpdates()

Enables updates to the query results.

func disableUpdates()

Disables updates to the query results.

var operationQueue: OperationQueue?

The queue on which query result notifications are posted.