macOS/iOS API解説

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

目次

informativeText

INDEX>AppKit>NSAlert>

アラートウインドウに表示される本文文字列を返します

Objective-C

@property(copy) NSString *informativeText

Swift

var informativeText: String?

解説

アラートウインドウに表示される本文文字列を返します。

f:id:jjj777:20150210071214p:plain

設定値

( NSString * )
String?

文字列

フレームワーク

ApplicationKit

クラス

NSAlert

使用可能

10.3

編集時のバージョン

OS X 10.10

参照


例文

Objective-C

NSLog([alert informativeText]);

Swift

//NSAlert informativeText
    @IBAction func function012(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
        //1つめのボタン
        alert.addButtonWithTitle(NSLocalizedString("Stop", comment:""))
        //2つめのボタン
        alert.addButtonWithTitle(NSLocalizedString("Continue", comment:""))
        
        var aButton :NSButton = alert.suppressionButton!
        NSLog("---%@", aButton.title)
        alert.showsSuppressionButton = true
        alert.delegate = self
        //シートを出す
        alert.beginSheetModalForWindow(window) { responseCode in
            if NSAlertSecondButtonReturn == responseCode {
                NSLog("SecondButton")
            }
        }
    }