NSApplicationMain & UIApplicationMain

On the Cocoa platform, the NSApplicationMain (macOS) and UIApplicationMain (iOS) aspects can be used to annotate the application delegate class and to automatically have the compiler generate the main() entry point method.

Background

A Cocoa application, like every other executable, needs to provide an Entry Point method called Main() where execution starts when the app is launched. Traditionally, this would be a regular static method that would call the NSApplicationMain or UIApoplicationMain Cocoa function, passing the name or type of the AppDelegate class. NSApplicationMain or UIApplicationMain would then launch the Cocoa or Cocoa Touch runtime to get the application's user interface up and running, among other things creating an instance of the AppDelegate class and calling the appropriate callbacks on it, such as applicationDidFinishLaunching or its variants.

When using the NSApplicationMain (macOS) or UIApplicationMain (iOS and tvOS) aspects on the AppDelegate class, the compiler takes care of this boilerplate code.

type
  [UIApplicationDelegate]
  MyAppDelegate = public class(IUIApplicationDelegate)
  public 
    method application(aApplication: UIApplication) didFinishLaunchingWithOptions( aLaunchOptions: NSDictionary): Boolean;
    begin
      ...
      
  [UIApplicationDelegate]
  public class MyAppDelegate : IUIApplicationDelegate
  {
    public bool application(UIApplication application) didFinishLaunchingWithOptions( NSDictionary launchOptions)
    {
      ...
  @UIApplicationDelegate
  public class MyAppDelegate :IUIApplicationDelegate {
  
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
      ...
  @UIApplicationDelegate
  public class MyAppDelegate implements IUIApplicationDelegate
  {
    public boolean application(UIApplication application) didFinishLaunchingWithOptions( NSDictionary launchOptions)
    {
      ...
  <UIApplicationDelegate>
  Public Class MyAppDelegate 
    Implements IUIApplicationDelegate
  
    Public Function Application(application As UIApplication, didFinishLaunchingWithOptions launchOptions As NSDictionary) As Boolean
      ...

Cocoa Only

The NSApplicationMain & UIApplicationMain aspects are available on the Cocoa platform only.

Defined in RemObjects.Elements.Cirrus.dll.