pub struct App<T = (), M = ()> {
pub objc: Id<Object>,
pub objc_delegate: Id<Object>,
pub delegate: Box<T>,
pub pool: AutoReleasePool,
/* private fields */
}
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
sourceimpl<T> App<T> where
T: AppDelegate + 'static,
impl<T> App<T> where
T: AppDelegate + 'static,
sourceimpl<T, M> App<T, M> where
M: Send + Sync + 'static,
T: AppDelegate + Dispatcher<Message = M>,
impl<T, M> App<T, M> where
M: Send + Sync + 'static,
T: AppDelegate + Dispatcher<Message = M>,
sourcepub fn dispatch_main(message: M)
pub fn dispatch_main(message: M)
Dispatches a message by grabbing the sharedApplication
, getting ahold of the delegate,
and passing back through there.
sourcepub fn dispatch_background(message: M)
pub fn dispatch_background(message: M)
Dispatches a message by grabbing the sharedApplication
, getting ahold of the delegate,
and passing back through there.
sourceimpl App
impl App
sourcepub fn register_for_remote_notifications()
pub fn register_for_remote_notifications()
Registers for remote notifications from APNS.
sourcepub fn unregister_for_remote_notifications()
pub fn unregister_for_remote_notifications()
Unregisters for remote notifications from APNS.
sourcepub fn set_relaunch_on_login(relaunch: bool)
pub fn set_relaunch_on_login(relaunch: bool)
Sets whether this application should relaunch at login.
sourcepub fn reply_to_termination_request(should_terminate: bool)
pub fn reply_to_termination_request(should_terminate: bool)
Respond to a termination request. Generally done after returning TerminateResponse::Later
from your trait implementation of should_terminate()
.
sourcepub fn reply_to_open_or_print(response: AppDelegateResponse)
pub fn reply_to_open_or_print(response: AppDelegateResponse)
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.
Trait Implementations
Auto Trait Implementations
impl<T, M> RefUnwindSafe for App<T, M> where
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, M> Send for App<T, M> where
M: Send,
T: Send,
impl<T, M> Sync for App<T, M> where
M: Sync,
T: Sync,
impl<T, M> Unpin for App<T, M> where
M: Unpin,
impl<T, M> UnwindSafe for App<T, M> where
M: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more