NSMetadataQuery
A query that you perform against Spotlight metadata.
Declaration
class NSMetadataQueryOverview
The NSMetadataQuery class encapsulates the functionality provided by the MDQuery opaque type for querying the Spotlight metadata.
NSMetadataQuery objects provide metadata query results in several ways:
As individual attribute values for requested attributes.
As value lists that contain the distinct values for given attributes in the query results.
As a result array proxy, containing all the query results. This is suitable for use with Cocoa bindings.
As a hierarchical collection of results, grouping together items with the same values for specified grouping attributes. This is also suitable for use with Cocoa bindings.
Queries have two phases: the initial gathering phase that collects all currently matching results and a second live-update phase.
By default, the receiver has no limitation on its search scope. Use the searchScopes property to customize.
By default, notification of updated results occurs at 1.0 seconds. Use the notificationBatchingInterval property to customize.
You must set a predicate with the predicate property before starting a query.
Topics
Configuring Queries
searchScopespredicatesortDescriptorsvalueListAttributesgroupingAttributesnotificationBatchingIntervaldelegatesearchItems
Running Queries
Getting Query Results
resultsresultCountresult(at:)index(ofResult:)groupedResultsNSMetadataQueryResultGroupenumerateResults(_:)enumerateResults(options:using:)valueListsNSMetadataQueryAttributeValueTuplevalue(ofAttribute:forResultAt:)enableUpdates()disableUpdates()operationQueue
Constants
Notifications
NSMetadataQueryDidFinishGatheringNSMetadataQueryDidStartGatheringNSMetadataQueryDidUpdateNSMetadataQueryGatheringProgress