Class List Method List File List

# Class: OSX::NSApplication

Inherits:
  Object
  - Object
  - OSX::NSApplication
  show all
Defined in:
  src/ruby/osx/objc/cocoa_macros_appkit.rb

## Overview

Utility functions for NSApplication.

## Defined Under Namespace

Classes: RBCCTemporaryDelegate

## Class Method Summary (collapse)

- + (Object) run_with_temp_app(terminate = true, &proc)

  Runs given block as a Cocoa application.

## Class Method Details

### + (`Object`) run_with_temp_app(terminate = true, &proc)

Runs given block as a Cocoa application.

Examples:

    OSX::NSApplication.run_with_temp_app do
        # do something
    end

Parameters:

- terminate (`Boolean`) (defaults to: `true`) —

  Whether app terminates after done given block or not

    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    # File 'src/ruby/osx/objc/cocoa_macros_appkit.rb', line 37

    def NSApplication.run_with_temp_app(terminate = true, &proc)
      # prepare delegate
      delegate = RBCCTemporaryDelegate.alloc.init
      delegate.proc = proc
      delegate.terminate = terminate
      # run a new app
      app = NSApplication.sharedApplication
      app.setDelegate(delegate)
      app.run
    end