SpotlightQuery.Constructor(query as String)
From Xojo Documentation
Constructor
This method is only available on the macOS platform. For cross-platform compatibility, use #If...#Endif with the Target... specifiers to make sure you will not attempt to use this method on an incompatible platform. |
Creates a SpotlightQuery object, optionally with the passed query. If not passed, it defaults to no query.
Example
The following synchronous query populates a ListBox with the list of audio files on the user’s computer and the absolute path to each file. You can put the code in a PushButton.
Var query As New SpotlightQuery("kMDItemContentTypeTree == 'public.audio'")
query.Synchronous = True
query.Run
For i As Integer = 0 To query.Count - 1
ListBox1.AddRow(query.Item(i).File.DisplayName)
ListBox1.CellValueAt(ListBox1.LastAddedRowIndex, 1) = query.Item(i).File.NativePath
Next
Exception e As SpotlightException
MessageBox("A Spotlight error occurred.")
query.Synchronous = True
query.Run
For i As Integer = 0 To query.Count - 1
ListBox1.AddRow(query.Item(i).File.DisplayName)
ListBox1.CellValueAt(ListBox1.LastAddedRowIndex, 1) = query.Item(i).File.NativePath
Next
Exception e As SpotlightException
MessageBox("A Spotlight error occurred.")