Method

# App

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

## Description

Returns the instance of the appropriate application object used by the <span class="title-ref">App</span>. This varies by project type.

## Usage

``` xojo
App.Property = value
```

Or

``` xojo
App.Method
```

| Part     | Description                                                                                                                                                                                                                                                                                                                                                           |
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Property | Any valid property of the appropriate `DesktopApplication</api/user_interface/desktop/desktopapplication>`, `WebApplication</api/web/webapplication>`, `ConsoleApplication</api/console/consoleapplication>`, `ServiceApplication</api/console/serviceapplication>`, `MobileApplication</api/mobile/mobileapplication>` class (based on your project type).           |
| value    | Any valid method or property of the appropriate `DesktopApplication</api/user_interface/desktop/desktopapplication>`, `WebApplication</api/web/webapplication>`, `ConsoleApplication</api/console/consoleapplication>`, `ServiceApplication</api/console/serviceapplication>`, `MobileApplication</api/mobile/mobileapplication>` class (based on your project type). |
| Method   | Any valid method of the appropriate `DesktopApplication</api/user_interface/desktop/desktopapplication>`, `WebApplication</api/web/webapplication>`, `ConsoleApplication</api/console/consoleapplication>`, `ServiceApplication</api/console/serviceapplication>`, `MobileApplication</api/mobile/mobileapplication>` class (based on your project type).             |

## Notes

This method returns a specific instance of an application class, depending on the <span class="title-ref">App</span> type:

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

### Global information

The application class can be a useful place to store information that needs to be global for the project. For example, an <span class="title-ref">App</span> might store its preferences in a Dictionary as a public property of the <span class="title-ref">App</span> object to make it accessible throughout the project. When you do this, you refer to the property by using the <span class="title-ref">App</span> prefix:

``` xojo
App.PreferencesDict.Value("DefaultUser") = "Tina"
```

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

### <span class="title-ref">App</span> can return Nil

It is possible for the <span class="title-ref">App</span> method to return `Nil</api/language/nil>` under certain circumstances. The <span class="title-ref">App</span> method returns the global application object only after it has been registered with the runtime. That means that any operations which happen before this registration process cannot rely on <span class="title-ref">App</span> returning non-nil. This is concern only very early in the program initialization stages; by the time the Application.Opening event fires you can be certain that <span class="title-ref">App</span> will return non-nil. The most common cases for <span class="title-ref">App</span> returning `Nil</api/language/nil>` are:

- Within a constructor for the Application object itself.
- Within menu item constructors when the menu bar is attached to the <span class="title-ref">App</span> class.

It is possible that there are other cases, so do not rely on these being the only two.

## Sample code

In a desktop or web <span class="title-ref">App</span>, turns on AutoQuit so that the <span class="title-ref">App</span> quits when all its Windows are closed or all its Sessions are disconnected:

``` xojo
App.AutoQuit = True
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`DesktopApplication</api/user_interface/desktop/desktopapplication>`, `ConsoleApplication</api/console/consoleapplication>`, `Session</api/web/session>`, `ServiceApplication</api/console/serviceapplication>`, `WebApplication</api/web/webapplication>`, `WebSession</api/web/websession>`, `MobileApplication</api/mobile/mobileapplication>` classes

</div>
