shared
共有アプリケーションオブジェクトを返します
解説
アプリケーションを返します。まだ存在しなければ、つくって返します。グローバル変数NSAppも同様。NSApplicationインスタンス(グローバル変数NSApp)を返します。
Objective-C
+ (NSApplication *)sharedApplication
Swift
open class var shared: NSApplication { get }
返り値
( NSApplication * )
共有アプリケーションオブジェクト
引数
なし
フレームワーク
ApplicationKit
クラス
NSApplication
使用可能
10.0-
更新時のバージョン
0S X 10.14.5
Swift4.2
参照
例文
#import "Controller.h" @implementation Controller - (IBAction)pushButton:(id)sender { [[NSApplication sharedApplication] orderFrontStandardAboutPanel:nil]; } - (void)applicationWillUpdate:(NSNotification *)aNotification { NSLog(@"applicationWillUpdate"); } @end
Swift4.2
//NSApplication.shared func function001() { let anApplication = NSApplication.shared print("Shared Application Object: \(anApplication).") }
Swift
func function001() { let anApplication = NSApplication.sharedApplication() NSLog("Shared Application Object: \(anApplication).") }