macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

modalWindow

INDEX>AppKit>NSApplication

アプリケーションのモーダルウインドウを返します

Objective-C

@property(readonly, strong) NSWindow *modalWindow

Swift

var modalWindow: NSWindow? { get }

解説

アプリケーションのモーダルウインドウを返します。
モーダルウインドウがなければnilを返します。

設定値

Objective-C

( NSWindow * )

表示しているモーダルウインドウ

Swift

NSWindow? { get }

表示しているモーダルウインドウ(読み込みのみ)

引数

なし

フレームワーク

ApplicationKit

クラス

NSApplication

使用可能

10.0

編集時のバージョン

OS X 10.10

参照

Swift
Swift - Display window as modal



Swift Programming Blog - Introduction to Swifter

例文

Objective-C

#import "Controller.h"

@implementation Controller

- (IBAction)pushButton:(id)sender
{
	NSInteger a=[[NSApplication sharedApplication] runModalForWindow:panel];
	NSLog(@"modai %d",a);
}

- (IBAction)panelButton:(id)sender;//ボタンを押す
{
	NSWindow *aWindow = [NSApp modalWindow];
	NSLog([aWindow description]);
}
@end

Swift

    //NSApplication modalWindow
    @IBAction func function023(sender: AnyObject) {
        //共有アプリケーションインスタンスを取得
        let anApplication = MyApplication.sharedApplication()
        //
        NSLog("%@",anApplication.modalWindow!)
        
    }