Class

# SpotlightItem

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to manage results from a `SpotlightQuery</api/macos/spotlightquery>`. Supported only on macOS. It does nothing on other operating systems.

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                           | Parameters                              | Returns                             | Shared |
|--------------------------------|-----------------------------------------|-------------------------------------|--------|
| `File<spotlightitem.file>`     |                                         | `FolderItem</api/files/folderitem>` |        |
| `Handle<spotlightitem.handle>` |                                         | `Integer</api/data_types/integer>`  |        |
| `Value<spotlightitem.value>`   | key As `String</api/data_types/string>` | `Variant</api/data_types/variant>`  |        |

## Method descriptions

<div id="spotlightitem.file">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SpotlightItem.File

**File** As `FolderItem</api/files/folderitem>`

> References the file that this <span class="title-ref">SpotlightItem</span> represents.
>
> This example uses File to access two items for each file in the loop.
>
> ``` xojo
> 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.CellTextAt(ListBox1.LastAddedRowIndex, 1) = query.Item(i).Value("kMDItemDurationSeconds")
> Next
>
> Exception e As SpotlightException
>   MessageBox("A Spotlight error occurred.")
> ```

<div id="spotlightitem.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SpotlightItem.Handle

**Handle** As `Integer</api/data_types/integer>`

> Returns a handle to an MDItemRef.
>
> This can be used in `Declare</api/language/declare>` statements to access features that are not provided by `SpotlightQuery</api/macos/spotlightquery>`.

<div id="spotlightitem.value">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SpotlightItem.Value

**Value**(key As `String</api/data_types/string>`) As `Variant</api/data_types/variant>`

> Returns the value of the specified property.
>
> The properties can be any of the ones listed in MDItem.h or any custom properties. Value returns `Nil</api/language/nil>` if the specified property is not present.
>
> This example displays the name and the duration of the audio file in a `ListBox</api/user_interface/desktop/desktoplistbox>`.
>
> ``` xojo
> 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.CellTextAt(ListBox1.LastAddedRowIndex, 1) = query.Item(i).Value("kMDItemDurationSeconds")
> Next
>
> Exception e As SpotlightException
>   MessageBox("A Spotlight error occurred.")
> ```

## Compatibility

|                       |                       |
|-----------------------|-----------------------|
| **Project Types**     | Console, Desktop, Web |
| **Operating Systems** | macOS                 |

<div class="seealso">

object parent class; `SpotlightException</api/exceptions/spotlightexception>`, `SpotlightQuery</api/macos/spotlightquery>` classes.

</div>
