NSApplicationクラス
アプリケーションのクラスです
継承 | NSObject |
準拠 | NSObject (NSObject) |
フレームワーク | /System/Library/Frameworks/AppKit.framework |
使用可能 | OS X 10.0以降 |
定義 | @import AppKit; |
概要
Macアプリケーションクラスです。
NSApplicationのサブクラスを使用する場合
オーバーライドした時には「アプリケーション設定」の「Cocoa固有の設定」をNSApplicationから、サブクラス(たとえばMyApplication)に変更しないといけません
Info.plistのNSPrincipalClassキーの値を(たとえば)MyApplicationにします。
<key>NSPrincipalClass</key> <string>MyApplication</string>
Swiftの場合、@objc(MyApplication)を使う
import AppKit @objc(MyApplication) class MyApplication: NSApplication { }
メソッドとプロパティ
アプリケーションの設定
サブクラスでアプリケーションが起動した時になにかさせる場合には(-finishLaunching)をオーバーライドします。
アプリケーションのデリゲートオブジェクトを返すには(delegate)を使います。
アプリケーションアイコンの画像を取得するには(applicationIconImage)を使用します。
-finishLaunching | 10.0- | アプリケーションが起動した時に呼び出されます |
delegate | 10.0- | デリゲートオブジェクトを返します |
applicationIconImage | 10.0- | アプリケーションアイコンの画像 |
アプリケーションの終了
アプリケーションを終了するには(terminate )を使用します。UIでcommand+Qを押した場合と同じです。
データを保存してから終了するなど、遅延終了する場合には、(-replyToApplicationShouldTerminate: )を使用します。
terminate | 10.0- | アプリケーションを終了します |
-replyToApplicationShouldTerminate: | 10.0- | 遅延終了する際に使用します |
エラーハンドリング
現在のイベントを取得するには、currentEventを使用します。
イベントキューから次のイベントを取得するには-nextEventMatchingMask:untilDate:inMode:dequeue: を使用します。
イベントキューからイベントを取り除くには、-discardEventsMatchingMask:beforeEvent: を使用します。
currentEvent | 10.0- | 現在のイベントを取得する |
-nextEventMatchingMask:untilDate:inMode:dequeue: | 10.0- | イベントキューから次のイベントを取得する |
-discardEventsMatchingMask:beforeEvent: | 10.0- | イベントキューからイベントを取り除く |
イベントループの管理
isRunning | 10.10- | メインイベントループが実行されているか |
run | 10.0- | |
-stop: | 10.0- | メインイベントループを停止します |
-sendEvent: | 10.0- | |
-postEvent:atStart: | 10.0- | |
リモート通知の管理
enabledRemoteNotificationTypes | 10.7- | 有効なリモート通知のタイプを取得 |
-registerForRemoteNotificationTypes: | 10.7- | リモート通知を登録します |
-unregisterForRemoteNotifications | 10.7- | リモート通知を解除します |
モーダルウインドウの管理
runModal | 10.0- | 指定したウインドウでモーダルを開始します |
-stopModal | 10.0- | モーダルを停止します |
-stopModalWithCode: | 10.0- | モーダルを停止する。判定のための整数コードを渡すことが出来ます |
-abortModal | 10.0- | イベントループを中断します |
-beginModalSessionForWindow: | 10.0- | モーダルセッションを開始します |
-runModalSession: | 10.0- | モーダルセッションを開始します |
-modalWindow | 10.0- | モーダルウインドウを返します |
-endModalSession: | 10.0- | モーダルセッションを終了します |
パネルの管理
カラーパネルを表示するには-orderFrontColorPanel: を使用します。
アバウトパネルを表示するには-orderFrontStandardAboutPanel: を使用します。
カラーパネルを表示するには-orderFrontColorPanel: を使用します。
アバウトパネルを表示するには-orderFrontStandardAboutPanel: を使用します。引数を渡して表示するには-orderFrontStandardAboutPanelWithOptions: を使用します。
文字パレットを表示するには-orderFrontCharacterPalette: を使用します。
印刷設定パレットを表示するには-runPageLayout: を使用します。
-orderFrontColorPanel: | 10.0- | カラーパネルを表示します |
-orderFrontStandardAboutPanel: | 10.0- | アバウトパネルを表示します |
-orderFrontStandardAboutPanelWithOptions: | 10.0- | 引数を渡してアバウトパネルを表示します |
-orderFrontCharacterPalette: | 10.0- | 文字パレットを表示します |
-runPageLayout: | 10.0- | 印刷設定パネルを表示します |
ウインドウの状態保存
-extendStateRestoration | 10.7- | |
-completeStateRestoration | 10.7- | |
restoreWindowWithIdentifier:state:completionHandler: | 10.7- |
ユーザーインターフェースのレイアウト方向
userInterfaceLayoutDirection | 10.6- | ユーザーインターフェースの向き |
ウインドウの管理
アプリケーションのキーウインドウ(キー入力を受け付けるウインドウ)を取得するには-keyWindowを使用します。
アプリケーションのメインウインドウを取得するにはmainWindow を使用します。
指定した番号のウインドウを取得するには-windowWithWindowNumber: を使用します。
すべてのウインドを配列で得るには-windowsを使用します。
アプリケーションのすべてのウインドウに引数が一つのメッセージを送信するには-makeWindowsPerform:inOrder: を使用します。
-keyWindow | 10.0- | キーウインドウ |
mainWindow | 10.0- | メインウインドウ |
-windowWithWindowNumber: | 10.0- | 指定したウインドウ番号のウインドウ |
-windows | 10.0- | ウインドウを配列で返します |
-makeWindowsPerform:inOrder: | 10.0- | ウインドウにメッセージを送信します |
ウインドウの最小化
アプリケーションのウインドウをすべて最小化するには|-miniaturizeAll: を使用します。
-miniaturizeAll: | 10.0- | すべてのウインドウを最小化します |
ウインドウを隠す
isHidden | 10.10- | アプリケーションが隠れているか |
hide: | 10.0- | アプリケーションを隠す |
unhide: | 10.0- | 隠れているアプリケーションを表示する |
unhideWithoutActivation | 10.0- | アクティブ状態に関係なく表示にする |
ウインドウのアップデート
updateWindows | 10.0- | ウインドウのアップデート |
-setWindowsNeedUpdate: | 10.0- | ウインドウのアップデートをする |
ウインドウレイヤーの管理
preventWindowOrdering | 10.0- | 最新のマウスダウンイベントを処理する際の通常のウィンドウの順序を抑制します |
-arrangeInFront: | 10.0- |
メインメニューへのアクセス
mainMenu | 10.0- | アプリケーションのメインメニュー |
ウインドウメニューの管理
windowsMenu | 10.0- | アプリケーションの「ウインドウ」メニュー |
addWindowsItem : title:filename: | 10.0- | ウインドウメニューに追加します |
changeWindowsItem | 10.0- | ウインドウメニューの指定したウインドウのタイトルを変更します |
removeWindowsItem: | 10.0- | 指定したウインドウをウインドウメニューから削除します |
updateWindowsItem: | 10.0- | メニューアイテムをアップデートします |
ドックタイルのアクセス
-dockTile | 10.5- | アプリケーションのドックタイル |
サービスメニューの管理
registerServicesMenuSendTypes:returnTypes: | 10.0- | サービスメニューを登録します* |
servicesMenu | 10.0- | サービスメニューを返します |
アプリケーションのアクティベーションサービスの管理
active | 10.10- | アプリケーションがアクティブかどうか |
activateIgnoringOtherApps: | 10.0- | 他のアプリケーションに関係なくアクティブにします |
deactivate | 10.0- | アプリケーションをアクティブでなくします |
アプリケーションを隠す
hideOtherApplications: | 10.0- | 他の全てのアプリケーションを隠します |
unhideAllApplications: | 10.0- | すべてのアプリケーションを表示します |
サービスの提供
validRequestorForSendType:returnType: | 10.0- | * |
servicesProvider | 10.0- | サービスプロバイダを返します |
ヘルプの表示
-showHelp: | 10.0- | ヘルプを表示します |
activateContextHelpMode: | 10.0- | アクティブコンテキストヘルプモードにします |
helpMenu | 10.6- | ヘルプメニュー |
スレッドの管理
detachDrawingThread:toTarget:withObject: | 10.0- | 新しいオートリリースプールを作って、スレッドを実行します |
アクションのポスト
tryToPerform:with: | 10.0- | アクションメッセージを送ってみます |
sendAction:to:from: | 10.0- | ターゲットにメッセージを送信します |
targetForAction: | 10.0- | アクションメッセージを受けるオブジェクトを返します |
targetForAction:to:from: | 10.0- | アクションメッセージを受けるオブジェクトを返します |
ウインドウの描画
context | 10.0- | アプリケーションのディスプレイコンテキストを返します |
例外の記録
reportException: | 10.0- | 例外をLogに記入します(例外は起こしません) |
ユーザーのアテンションリクエストの管理
requestUserAttention: | 10.1- | アテンションリクエストを開始します |
cancelUserAttentionRequest: | 10.1- | アテンションリクエストを終了します |
-replyToOpenOrPrint: | 10.3- | openFiles,printFilesの結果の処理をします |
キーボードのアクセス
fullKeyboardAccessEnabled | 10.6- | フルキーボードアクセスが有効になっているか |
表示オプション(フルスクリーンモード・メニューバーの表示・非表示など)
currentSystemPresentationOptions | 10.6- | 現在のシステムのプレゼンテーションオプション |
presentationOptions | 10.6- | アプリケーションのプレゼンテーションオプション |
アクティベーションポリシー
activationPolicy | 10.6- | アプリケーションのアクティベーションポリシー |
setActivationPolicy: | 10.6- | アプリケーションのアクティベーションポリシーをセットする |
ヘルプのスポットライト(アプリケーションのHelp検索で使用する)
registerUserInterfaceItemSearchHandler:
10.6- アプリケーションのHelp検索で使用するハンドラを設定する
searchString:inUserInterfaceItemString:searchRange:foundRange:
10.6- 文字列の検索
unregisterUserInterfaceItemSearchHandler:
10.6- アプリケーションのHelp検索で使用するハンドラを設定解除
ログインで再起動の管理
disableRelaunchOnLogin | 10.7- | 再ログインした場合に自動起動しないようにセット |
enableRelaunchOnLogin | 10.7- | 再ログインした場合に自動起動するようにセット |
バックグラウンド・フォアグラウンドの状況の管理
occlusionState | 10.9- | バックグラウンド・フォアグラウンドの状況 |
スクリプティング
orderedDocuments | 10.0- | ドキュメントベースアプリケーションでのドキュメントの配列 |
orderedWindows | 10.0- | ウインドウの数 |
非推奨
-runModalForWindow:relativeToWindow: (OS X v10.0) | 10.0-10.0 | モーダルウインドウを開始する |
beginModalSessionForWindow: relativeToWindow: (OS X v10.0) | 10.0-10.0 | モーダルセッションを開始する |
-beginSheet:modalForWindow: modalDelegate:didEndSelector:contextInfo: (OS X v10.10) | 10.0-10.0 | モーダルセッションを開始する |
endSheet: (OS X v10.10) | 10.0-10.10 | シートウインドウを指定して、文書モーダルセッションを終わります |
-endSheet:returnCode: (OS X v10.10) | 10.0-10.10 | シートを終了する |
データタイプ
NSUserInterfaceLayoutDirection | 10.6- | ユーザーインターフェースの方向 |
NSModalResponse | 10.9- | モーダルの結果 |
NSRequestUserAttentionType | 10.1- | 要求するユーザーのアテンションタイプ |
NSApplicationDelegateReply | 10.3- | デリゲートのリプライタイプ |
NSApplicationPresentationOptions | 10.6- | アプリケーションの表示オプション |
NSApplicationTerminateReply | 10.0- | アプリケーション終了の返答 |
NSApplicationPrintReply | 10.4- | 印刷の返答 |
NSApplicationOcclusionState | 10.9- | アプリケーション表示の状態 |
定数
NSApp | 10.0- | アプリケーションの共有インスタンス |
Return values for modal operations | 10.0-10.10 | |
NSUpdateWindowsRunLoopOrdering | 10.0- | |
Run loop modes | 10.0- | |
NSApplicationDidFinishLaunching | 10.7-10.8 | |
User Info Keys | ||
NSRemoteNotificationType | 10.7- | リモート通知のタイプ |
NSAppKitVersionNumber | 10.1- | AppKitのバージョン番号 |
AppKit framework version numbers | 10.0- |
通知
NSApplicationDidBecomeActiveNotification | 10.0- | アプリケーションがアクティブになればポストされる通知 |
NSApplicationDidChangeScreenParametersNotification | 10.0- | スクリーンの属性が変更された時にポストされる通知 |
NSApplicationDidFinishLaunchingNotification | 10.0- | アプリケーションの起動が完了したときの通知 |
NSApplicationDidHideNotification | 10.0- | アプリケーションが隠された時の通知 |
NSApplicationDidResignActiveNotification | 10.0- | アクティブなアプリケーションが他へ移った |
NSApplicationDidUnhideNotification | 10.0- | アプリケーションが隠れている状態から戻った後の通知 |
NSApplicationDidUpdateNotification | 10.0- | アプリケーションがアップデートされた後に呼ばれる通知 |
NSApplicationWillBecomeActiveNotification | 10.0- | |
NSApplicationWillFinishLaunchingNotification | 10.0- | |
NSApplicationWillHideNotification | 10.0- | |
NSApplicationWillResignActiveNotification | 10.0- | |
NSApplicationWillTerminateNotification | 10.0- | |
NSApplicationWillUnhideNotification | 10.0- | |
NSApplicationWillUpdateNotification | 10.0- | |
NSApplicationDidFinishRestoringWindowsNotification | 10.7- | |
NSApplicationDidChangeOcclusionStateNotification | 10.9- | |
Apple MacBook Pro (13インチ, Touch Bar, 1.4GHzクアッドコアIntel Core i5, 8GB RAM, 128GB) - スペースグレイ (最新モデル)
- 出版社/メーカー: アップル
- 発売日: 2019/07/10
- メディア: Personal Computers
- この商品を含むブログを見る