Instance Method


Initializes and returns a query object with the specified query string and item attributes.


- (instancetype)initWithQueryString:(NSString *)queryString attributes:(NSArray<NSString *> *)attributes;



A formatted string that defines the matching criteria to apply to indexed items. To learn how to construct a query string, see Creating a Query String.

This parameter must not be nil.


An array of strings that represent the attributes of indexed items. Each string corresponds to a property name that can be set for an item; for a list of possible properties, see CSSearchableItemAttributeSet. Passing nil for this parameter means that the query does not use attributes to find matching items.

Return Value

An initialized query object.


After you create and initialize a query object, and call start to begin the query, you can’t update or reuse the query object for a new query.

See Also

Creating a Query Object


Provides the key within the NSUserActivity object’s userInfo dictionary for which the value is the string that represents the user’s current query.


Indicates that the activity type to continue is a search or query.


An array of data protection classes that correspond to the protection classes associated with the indexed items.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software