Class

# ObjectIterator

<div class="rst-class">

forsearch

</div>

Introspection

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

## Description

Used to iterate over the active objects at runtime. Use the `Introspection</api/language/introspection/introspection>` system to get information on the active objects. Note that <span class="title-ref">ObjectIterator</span> is a Public class of the `Runtime</api/language/runtime>` module.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                              | Type                                              | Read-Only | Shared |
|-----------------------------------|---------------------------------------------------|-----------|--------|
| `Current<objectiterator.current>` | `Object</api/data_types/additional_types/object>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                | Parameters | Returns                            | Shared |
|-------------------------------------|------------|------------------------------------|--------|
| `MoveNext<objectiterator.movenext>` |            | `Boolean</api/data_types/boolean>` |        |
| `Reset<objectiterator.reset>`       |            |                                    |        |

## Property descriptions

<div id="objectiterator.current">

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

</div>

<div class="rst-class">

forsearch

</div>

ObjectIterator.Current

**Current** As `Object</api/data_types/additional_types/object>`

> The current object whose `TypeInfo</api/language/introspection/typeinfo>` is available.
>
> This property is read-only.
>
> This call to Current gets the Name of the object.
>
> ``` xojo
> Var o As Runtime.ObjectIterator = Runtime.IterateObjects
> o.Reset
>
> While o.MoveNext
>   ListBox1.AddRow(Introspection.GetType(o.Current).Name)
> Wend
> ```

## Method descriptions

<div id="objectiterator.movenext">

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

</div>

<div class="rst-class">

forsearch

</div>

ObjectIterator.MoveNext

**MoveNext** As `Boolean</api/data_types/boolean>`

> Moves the iterator to the next object. MoveNext must be called to start the iteration. You can think of the iterator as initially pointing to prior to the first item in the list.
>
> The following example iterates over the objects using a `While</api/language/loops/while...wend>` loop and writes each object's name to a `DesktopListBox</api/user_interface/desktop/desktoplistbox>`.
>
> ``` xojo
> Var o As Runtime.ObjectIterator = Runtime.IterateObjects
>
> While o.MoveNext
>   ListBox1.AddRow(Introspection.GetType(o.Current).Name)
> Wend
> ```

<div id="objectiterator.reset">

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

</div>

<div class="rst-class">

forsearch

</div>

ObjectIterator.Reset

**Reset**

> Sets the iterator back to its initial state so that a call to MoveNext will go to the first item in the list.
>
> The following example iterates over the objects using a `While</api/language/loops/while...wend>` loop and writes each object's name to a `DesktopListBox</api/user_interface/desktop/desktoplistbox>`.
>
> ``` xojo
> Var o As Runtime.ObjectIterator = Runtime.IterateObjects
> o.Reset
>
> While o.MoveNext
>   ListBox1.AddRow(Introspection.GetType(o.Current).Name)
> Wend
> ```

## Sample code

The following example iterates over the objects using a `While</api/language/loops/while...wend>` loop and writes each object's name to a `DesktopListBox</api/user_interface/desktop/desktoplistbox>`.

``` xojo
Var o As Runtime.ObjectIterator = Runtime.IterateObjects
While o.MoveNext
  ListBox1.AddRow(Introspection.GetType(o.Current).Name)
Wend
```

## Compatibility

|                       |                               |
|-----------------------|-------------------------------|
| **Project Types**     | Console, Desktop, Mobile, Web |
| **Operating Systems** | iOS, Linux, macOS, Windows    |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `Introspection</api/language/introspection/introspection>`, `Runtime</api/language/runtime>` modules; `TypeInfo</api/language/introspection/typeinfo>` class.

</div>
