Class: NSMetadataQuery

Inherits:
NSObject show all

Overview

The NSMetadataQuery class encapsulates the functionality provided by the MDQuery opaque type for querying the Spotlight metadata.

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Method Details

- (Object) delegate

Returns the receiver’s delegate.

Returns:

  • (Object)

    The receiver’s delegate, or nil if there is none.

- (Object) disableUpdates

Disables updates to the query results. You should invoke this method before iterating over query results that could change due to live updates.

Returns:

- (Object) enableUpdates

Enables updates to the query results. You should invoke this method after you’re done iterating over the query results.

Returns:

- (Array) groupedResults

Returns an array containing hierarchical groups of query results based on the receiver’s grouping attributes.

Returns:

  • (Array)

    Array containing hierarchical groups of query results.

- (Array) groupingAttributes

Returns the receiver’s grouping attributes.

Returns:

  • (Array)

    Array containing grouping attributes.

- (Integer) indexOfResult(result)

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

Parameters:

  • result (Object)

    Query result object being inquired about.

Returns:

  • (Integer)

    Index of result in the query result array.

- (Object) init

Initializes an allocated NSMetadataQuery object.

Returns:

- (Boolean) isGathering

Returns a Boolean value that indicates whether the receiver is in the initial gathering phase of the query.

Returns:

  • (Boolean)

    YES when the query is in the initial gathering phase; NO otherwise.

- (Boolean) isStarted

Returns a Boolean value that indicates whether the receiver has started the query.

Returns:

  • (Boolean)

    YES when the receiver has executed the startQuery method; NO otherwise.

- (Boolean) isStopped

Returns a Boolean value that indicates whether the receiver has stopped the query.

Returns:

  • (Boolean)

    YES when the receiver has stopped the query, NO otherwise.

- (NSTimeInterval) notificationBatchingInterval

Returns the interval that the receiver provides notification of updated query results.

Returns:

  • (NSTimeInterval)

    The interval at which notification of updated results occurs.

- (NSPredicate) predicate

Returns the predicate the receiver uses to filter query results.

Returns:

  • (NSPredicate)

    The predicate used to filter query results.

- (Object) resultAtIndex(index)

Returns the query result at a specific index. For performance reasons, you should use this method when retrieving a specific result, rather than they array returned by results.

Parameters:

  • index (Integer)

    Index of the desired result in the query result array.

Returns:

  • (Object)

    Query result at the position specified by index.

- (Integer) resultCount

Returns the number of results returned by the receiver. For performance reasons, you should use this method, rather than invoking count on results.

Returns:

  • (Integer)

    The number of objects the query produced.

- (Array) results

Returns an array containing the result objects for the receiver. The results 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 you should instead use the resultCount and resultAtIndex: methods.

Returns:

  • (Array)

    Proxy array containing query result objects.

- (Array) searchScopes

Returns an array containing the receiver’s search scopes. The array can contain NSString or NSURL objects that represent file system directories or the search scopes specified in “Constants.” An empty array indicates that there is no limitation on where the receiver searches.

Returns:

  • (Array)

    An array containing the receiver’s search scopes.

- (Object) setDelegate(delegate)

Sets the receiver’s delegate

Parameters:

  • delegate (Object)

    An object to serve as the receiver’s delegate. The delegate must implement the NSMetadataQueryDelegate Protocol protocol. Pass nil to remove the current delegate.

Returns:

- (Object) setGroupingAttributes(attributes)

Sets the receiver’s grouping attributes to specific attribute names. Invoking this method on a receiver while it’s running a query, stops the query and discards current results, and immediately starts a new query.

Parameters:

  • attributes (Array)

    Array containing attribute names.

Returns:

- (Object) setNotificationBatchingInterval(timeInterval)

Sets the interval between update notifications sent by the receiver.

Parameters:

  • Term (NSTimeInterval)

    The Interval at which notification of updated results is to occur.

Returns:

- (Object) setPredicate(predicate)

Sets the predicate used by the receiver to filter the query results. Invoking this method on a receiver running a query causes the existing query to stop, all current results are discarded, and a new query is started immediately.

Parameters:

  • predicate (NSPredicate)

    A predicate to be used to filter query results.

Returns:

- (Object) setSearchScopes(scopes)

Restrict the search scope of the receiver.

Parameters:

  • scopes (Array)

    Array of NSString or NSURL objects that specify file system directories. You can also include the predefined search scopes specified in “Constants.” An empty array removes search scope limitations.

Returns:

- (Object) setSortDescriptors(descriptors)

Sets the sort descriptors to be used by the receiver. Invoking this method on the receiver running a query causes the existing query to stop, all current results are discarded, and a new query is started immediately.

Parameters:

  • descriptors (Array)

    Array of sort descriptors.

Returns:

- (Object) setValueListAttributes(attributes)

Sets the value list attributes for the receiver to the specific attribute names. The query collects the values of these attributes into uniqued lists that can be used to summarize the results of the query. If attributess is nil, the query generates no value lists. Note that value list collection increases CPU usage and significantly increases the memory usage of an NSMetadataQuery object.Invoking this method on the receiver while it’s running a query, stops the query and discards current results, and immediately starts a new query.

Parameters:

  • attributes (Array)

    Array of value list attributes.

Returns:

- (Array) sortDescriptors

Returns an array containing the receiver’s sort descriptors.

Returns:

  • (Array)

    An array containing sort descriptors.

- (Boolean) startQuery

Attempts to start the query. A query can’t be started if the receiver is already running a query or no predicate has been specified.

Returns:

  • (Boolean)

    YES when successful; NO otherwise.

- (Object) stopQuery

Stops the receiver’s current query from gathering any further results. The receiver first completes gathering any unprocessed results. If a query is stopped before the gathering phase finishes, it will not post an NSMetadataQueryDidStartGatheringNotification notification.You would call this function to stop a query that is generating too many results to be useful but still want to access the available results. If the receiver is sent a startQuery message after performing this method, the existing results are discarded.

Returns:

- (Array) valueListAttributes

Returns an array containing the value list attributes the receiver generates.

Returns:

  • (Array)

    Array containing value list attributes.

- (Hash) valueLists

Returns a dictionary containing the value lists generated by the receiver.

Returns:

- (Object) valueOfAttribute(attributeName, forResultAtIndex:index)

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

Parameters:

  • attributeName (String)

    The attribute of the result object at index being inquired about. The attribute must be specified in setValueListAttributes:, as a sorting key in a specified sort descriptor, or as one of the grouping attributes specified set for the query.

  • index (Integer)

    Index of the desired return object in the query results array.

Returns:

  • (Object)

    Value for attributeName in the result object at index in the query result array.