Platforms to show: All Mac Windows Linux Cross-Platform

MDQueryMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Spotlight MBS MacOSX Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
MDQuery encapsulates all queries against the MetaData database.
Example
dim m as new MDQueryMBS("* == ""Hello""wcd || kMDItemTextContent = ""Hello""c")

call m.Execute(m.kMDQuerySynchronous)

MsgBox str(m.ResultCount) // shows a lot of results

Depending on what and how you want to search, you can decide whether MDQueryMBS or CatSearchMBS is the better choice.

Available in Mac OS X version 10.4 and later.

Queries gather results or process updates only while the current thread's run loop is running. Queries normally operate asynchronously, and only send out progress notificiations as the list is being collected. The query list is kept up to date with respect to value lists and sorting as the progress notifications are sent out, so the query is in a good state during those events.

An MDQuery presents its results as if it were a simple array object. The results are MDItem.

Query Sorting Sorting the results from a query can be performed in one of two ways. First is to let the library sort the results for you by passing an array of attributes to sort on to constructor. The default sort provided by the constructor is a assending sort strings are compared using CFStringCompare() with the options kCFCompareNonliteral | kCFCompareLocalized | kCFCompareNumerically.

If used in a thread, please use a loop with calling NSRunLoopMBS.currentRunLoop.runUntilDate(nil) to give time for update events to fire.

Constants

Constant Value Description
kMDQueryReverseSortOrderFlag 1 A flag constant for calling SetSortOptionFlagsForAttribute. Sort the attribute in reverse order.
Available on Mac OS X 10.7 or later.
kMDQueryScopeAllIndexed "kMDQueryScopeAllIndexed" One of the option constants for the search scope. A constant, which can be passed in the scopeDirectories array, to specify that the search should be restricted to indexed, locally mounted volumes and indexed user mounted remote volumes, plus the user's home directory.
kMDQueryScopeComputer "kMDQueryScopeComputer" One of the option constants for the search scope. A constant, which can be passed in the scopeDirectories array, to specify that the search should be restricted to all locally mounted volumes, plus the user's home directory (which may be on a remote volume).
kMDQueryScopeComputerIndexed "kMDQueryScopeComputerIndexed" One of the option constants for the search scope. A constant, which can be passed in the scopeDirectories array, to specify that the search should be restricted to indexed, locally mounted volumes, plus the user's home directory (which may be on a remote volume).
kMDQueryScopeHome "kMDQueryScopeHome" One of the option constants for the search scope. A constant, which can be passed in the scopeDirectories array, to specify that the search should be restricted to the volume and directory that contains the current user's home directory
kMDQueryScopeNetwork "kMDQueryScopeNetwork" One of the option constants for the search scope. A constant, which can be passed in the scopeDirectories array, to specify that the search should include all user mounted remote volumes.
kMDQueryScopeNetworkIndexed "kMDQueryScopeNetworkIndexed" One of the option constants for the search scope. A constant, which can be passed in the scopeDirectories array, to specify that the search should include indexed user mounted remote volumes.
kMDQuerySynchronous 1 One of the constants for executing a query. Block during the gathering phase. If this parameter is true, the function will not return until the query has finished gathering the initial results. The run loop will run in the default mode, which will allow anything registered in that mode with this run loop to execute as well. If this parameter is false, the function returns immediately after starting the query asychronously.
kMDQueryWantsUpdates 4 One of the constants for executing a query. When set, after gathering the initial results the query will watch for changes in the system which should update the list of results. This can be changes which cause new files to now match the query, or changes which cause files in the result list to continue to match, or no longer match, the query. Files which begin to match the query are added to the result list, and files which no longer match the query expression are removed from the result list. more

This class has no sub classes.

Some examples using this class:

Blog Entries


The items on this page are in the following plugins: MBS MacOSX Plugin.


MDQueryBatchingParamsMBS   -   MediaKeysMBS


The biggest plugin in space...