Mac Developer Library

Developer

Foundation Framework Reference NSMetadataQueryDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSMetadataQueryDelegate

Inheritance


Not Applicable

Conforms To


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.6 and later.

The NSMetadataQueryDelegate protocol defines the optional methods implemented by delegates of NSMetadataQuery objects.

  • Implemented by the delegate to return a different object for a specific query result object.

    Declaration

    Swift

    optional func metadataQuery(_ query: NSMetadataQuery, replacementObjectForResultObject result: NSMetadataItem) -> AnyObject

    Objective-C

    - (id)metadataQuery:(NSMetadataQuery *)query replacementObjectForResultObject:(NSMetadataItem *)result

    Parameters

    query

    The query that produced the result object to replace.

    result

    The query result object to replace.

    Return Value

    Object that replaces the query result object.

    Discussion

    By default query result objects are instances of the NSMetadataItem class. By implementing this method, you can return an object of a different class type for the specified result object.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Implemented by the delegate to return a different value for a specific attribute.

    Declaration

    Swift

    optional func metadataQuery(_ query: NSMetadataQuery, replacementValueForAttribute attribute: String, value attributeValue: AnyObject) -> AnyObject

    Objective-C

    - (id)metadataQuery:(NSMetadataQuery *)query replacementValueForAttribute:(NSString *)attribute value:(id)attributeValue

    Parameters

    query

    The query that produced the result object with attribute.

    attribute

    The attribute in question.

    attributeValue

    The attribute value to replace.

    Return Value

    Object that replaces the value of attribute in the result object

    Discussion

    The delegate implementation of this method could convert specific query attribute values to other attribute values, for example, converting date object values to formatted strings for display.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

    Available as part of an informal protocol prior to OS X v10.6.