NNTagging Reference Library

NNQuery Class Reference

NNQuery Class Reference

Inherits from
Declared in NNQuery.h

Overview

Posted when the receiver's grouping attributes have changed. NNQuery is mainly a wrapper around the NSMetadataQuery class, and shares a lot of its API. There are additional methods for manipulating the search, as NNQuery uses NNTag instances instead of directly setting the NSPredicate.

Tasks

Instance Methods

executeSynchronousQueryForString:

- (NSArray *)executeSynchronousQueryForString:(NSString *)queryString
Parameters
queryString

Query string to execute

Return Value

TaggableObjects for query string

Discussion

Executes a synchronous query for the query string that will return the results immediately.

Declared In
NNQuery.h

executeSynchronousQuery

- (NSArray *)executeSynchronousQuery
Return Value

TaggableObjects for selected tags

Discussion

Executes a synchronous query that will return the results immediately.

Declared In
NNQuery.h

executeSynchronousQueryWithBundlingAttribute:

- (NSArray *)executeSynchronousQueryWithBundlingAttribute:(NSString *)attr
Parameters
attr

Bundling attribute, i.e. kMDItemContentTypeTree

Return Value

Bundles that contain taggableObjects for selected tags

Discussion

Executes a synchronous query that will return the bundled results immediately.

Declared In
NNQuery.h

init

- (id)init
Return Value

New query - use setTags: to set tags for searching

Declared In
NNQuery.h

initWithTags:

- (id)initWithTags:(NNSelectedTags *)otherTags
Parameters
otherTags

Tags to search for

Return Value

NNQuery ready to search for otherTags

Discussion

Designated initializer - call this one if you want to set the selected tags right away.

Declared In
NNQuery.h

tags

- (NNSelectedTags *)tags
Return Value

Tags the query is currently prepared to search for

Declared In
NNQuery.h

setTags:

- (void)setTags:(NNSelectedTags *)otherTags
Parameters
otherTags

Tags to search for

Declared In
NNQuery.h

startQuery

- (BOOL)startQuery
Return Value

YES when succesful, NO otherwise

Discussion

Starts the query

Declared In
NNQuery.h

stopQuery

- (void)stopQuery
Discussion

Stops the query

Declared In
NNQuery.h

disableUpdates

- (void)disableUpdates
Discussion

Temporarily stops the query from gathering results - use this if you e.g. want to display intermediate results.

Declared In
NNQuery.h

enableUpdates

- (void)enableUpdates
Discussion

Reenables result gathering - use this after disableUpdates.

Declared In
NNQuery.h

isStarted

- (BOOL)isStarted
Return Value

YES if query is started, NO otherwise

Declared In
NNQuery.h

isStopped

- (BOOL)isStopped
Return Value

YES if the query is stopped, NO otherwise

Declared In
NNQuery.h

isGathering

- (BOOL)isGathering
Return Value

YES if query is gathering results, NO otherwise

Discussion

This returns YES if the query is started and updating was not disabled.

Declared In
NNQuery.h

resultCount

- (NSUInteger)resultCount
Return Value

Number of results currently found

Declared In
NNQuery.h

resultAtIndex:

- (id)resultAtIndex:(NSUInteger)idx
Parameters
idx

Index of the result to return

Return Value

Result at position idx

Declared In
NNQuery.h

results

- (NSArray *)results
Return Value

Results that may contain a hierarchical tree of bundles or a flat list of items. This depends on the current bundling attributes.

Declared In
NNQuery.h

flatResults

- (NSArray *)flatResults
Return Value

Results as flat array

Declared In
NNQuery.h

flatPlainResults

- (NSMutableArray *)flatPlainResults
Return Value

Results as flat unfiltered array.

Declared In
NNQuery.h

bundlingAttributes

- (NSArray *)bundlingAttributes
Return Value

Bundling attributes as array

Declared In
NNQuery.h

setBundlingAttributes:

- (void)setBundlingAttributes:(NSArray *)attributes
Parameters
attributes

The new attributes to use

Discussion

Sets new bundling attributes

Declared In
NNQuery.h

filters

- (NSArray *)filters
Return Value

Array of NNQueryFilters

Declared In
NNQuery.h

setFilters:

- (void)setFilters:(NSMutableArray *)someFilters
Parameters
someFilters

Filters to use when executing the query

Declared In
NNQuery.h

addFilter:

- (void)addFilter:(NNQueryFilter *)filter
Parameters
filter

Filter to add

Discussion

Adds a filter to the query

Declared In
NNQuery.h

addFilters:

- (void)addFilters:(NSArray *)someFilters
Parameters
someFilters

Filters to add

Discussion

Adds multiple filters to the query

Declared In
NNQuery.h

removeFilter:

- (void)removeFilter:(NNQueryFilter *)filter
Parameters
filter

Filter to remove

Discussion

Removes a filter from the query

Declared In
NNQuery.h

removeAllFilters

- (void)removeAllFilters
Discussion

Removes all active query filters

Declared In
NNQuery.h

startDate

- (NSDate *)startDate
Return Value

startDate

Declared In
NNQuery.h

setStartDate:

- (void)setStartDate:(NSDate *)date
Parameters
date

Start date of tagged objects to return

Discussion

If a startDate is set, tagged objects will only be retrieved if they have been tagged AFTER the given date

Declared In
NNQuery.h

endDate

- (NSDate *)endDate
Return Value

endDate

Declared In
NNQuery.h

setEndDate:

- (void)setEndDate:(NSDate *)date
Parameters
date

End date of tagged objects to return

Discussion

If a endDate is set, tagged objects will only be retrieved if they have been tagged BEFORE the given date

Declared In
NNQuery.h

filterResults:usingValues:forBundlingAttribute:newBundlingAttributes:

- (void)filterResults:(BOOL)flag usingValues:(NSArray *)filterValues forBundlingAttribute:(NSString *)attribute newBundlingAttributes:(NSArray *)newAttributes
Parameters
flag

If YES filter is applied

filterValues

Array of values to use for the filter, e.g. "DOCUMENTS" or "PDF"

attribute

DEPRECATED - currently supposed to be "kMDItemContentTypeTree"

newAttributes

DEPRECATED

Discussion

TODO daniel

Applies new filter. may be set at any time even if the query is currently active. This has nothing to do with the filter methods above. filterResults: will filter gathered results, whereas the NNQueryFilters will constrain the query directly.

Declared In
NNQuery.h

hasResultsUsingFilterWithValues:forBundlingAttribute:

- (BOOL)hasResultsUsingFilterWithValues:(NSArray *)filterValues forBundlingAttribute:(NSArray *)attribute
Parameters
filterValues

Array of values to use for the filter, e.g. "DOCUMENTS" or "PDF"

attribute

Attribute to use, e.g. "kMDItemContentTypeTree"

Return Value

YES if there are results, NO otherwise

Discussion

Returns YES if there are results for the given filter.

Declared In
NNQuery.h

hasFilter

- (BOOL)hasFilter
Return Value

YES if there's currently a filter

Declared In
NNQuery.h

Last updated: 2010-5-13