macOS/iOS API解説

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

目次

runModal

INDEX>AppKit>NSAlert>

アラートウインドウを表示します。

10.9以降ではbeginSheetModalForWindow:completionHandlerを使用します。

- (NSModalResponse)runModal
func runModal() -> NSModalResponse

解説

アラートウインドウを表示します。

引数

なし

フレームワーク

ApplicationKit

クラス

NSAlert

使用可能

10.3

編集時のバージョン

OS X 10.10

参照

beginSheetModalForWindow:completionHandler
-beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:

例文

[alert setShowsHelp:YES];
[alert runModal];
//NSAlert runModal
    @IBAction func function009(sender: AnyObject) {
        //なにかモーダルがあっても終わり
        NSApp.abortModal()
        
        //テキストの作成
        let messageText:String = "Message text" as String
        let informativeText:String = "Information text" as String
        //NSAlertの作成
        let alert:NSAlert = NSAlert()
        alert.alertStyle = .WarningAlertStyle
        alert.messageText = messageText
        alert.informativeText = informativeText
        alert.delegate = self

        let response:Int = alert.runModal()
    }