ウィンドウが閉じられるとアプリケーションも終了するようにする。

元ネタ(objc)。RubyCocoaでやる方法。

Interface Builderにて

File's Owner→ControllerクラスインスタンスへCtrlドラッグ。
File's OwnerのdelegateにControllerクラスインスタンスを設定。アウトレット変数delegateにConnect。
(これでControllerクラスがNSAppのdelegate先になる)

コントローラクラス定義にて

  def applicationShouldTerminateAfterLastWindowClosed(sender)
    true
  end

追加