pub struct App<T = (), M = ()> {
    pub objc: Id<Object>,
    pub objc_delegate: Id<Object>,
    pub delegate: Box<T>,
    pub pool: AutoReleasePool,
    /* private fields */
}
Available on crate feature appkit only.
Expand description

A wrapper for NSApplication in AppKit/Cocoa, and UIApplication in UIKit/Cocoa Touch.

It holds (retains) a pointer to the Objective-C runtime shared application object, as well as handles setting up a few necessary pieces:

  • It injects an NSObject subclass to act as a delegate for lifecycle events.
  • It ensures that Cocoa, where appropriate, is operating in multi-threaded mode so POSIX threads work as intended.

This also enables support for dispatching a message, M. Your AppDelegate can optionally implement the Dispatcher trait to receive messages that you might dispatch from deeper in the application.

Fields

objc: Id<Object>

The underlying Objective-C Object.

objc_delegate: Id<Object>

The underlying Objective-C Object, which in this case is a delegate that forwards to the app delegate.

delegate: Box<T>

The stored AppDelegate.

pool: AutoReleasePool

The main-thread AutoReleasePool. Drains on app exit.

Implementations

Kicks off the NSRunLoop for the NSApplication instance. This blocks when called. If you’re wondering where to go from here… you need an AppDelegate that implements did_finish_launching. :)

Creates an NSAutoReleasePool, configures various NSApplication properties (e.g, activation policies), injects an NSObject delegate wrapper, and retains everything on the Objective-C side of things.

Dispatches a message by grabbing the sharedApplication, getting ahold of the delegate, and passing back through there.

Dispatches a message by grabbing the sharedApplication, getting ahold of the delegate, and passing back through there.

Registers for remote notifications from APNS.

Unregisters for remote notifications from APNS.

Sets whether this application should relaunch at login.

Respond to a termination request. Generally done after returning TerminateResponse::Later from your trait implementation of should_terminate().

An optional call that you can use for certain scenarios surrounding opening/printing files.

Sets a set of Menu’s as the top level Menu for the current application. Note that behind the scenes, Cocoa/AppKit make a copy of the menu you pass in - so we don’t retain it, and you shouldn’t bother to either.

For nib-less applications (which, if you’re here, this is) need to call the activation routines after the NSMenu has been set, otherwise it won’t be interact-able without switching away from the app and then coming back.

@TODO: Accept an ActivationPolicy enum or something.

Terminates the application, firing the requisite cleanup delegate methods in the process.

This is typically called when the user chooses to quit via the App menu.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.