macOS/iOS API解説

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

目次

doubleValue

INDEX>AppKit>NSControl

倍精度浮動小数点数値としてコントロールの値を設定

Objective-C

@property double doubleValue

Swift

var doubleValue: Double

解説

倍精度浮動小数点数値としてコントロールの値を設定。
複数のセルを含むコントロール(たとえばNSMatrixなど)なら、選択されたセルの値を返します。

フレームワーク

ApplicationKit

クラス

NSControl

使用可能

10.0

参照

cocoaapi.hatenablog.com
cocoaapi.hatenablog.com
cocoaapi.hatenablog.com
cocoaapi.hatenablog.com
cocoaapi.hatenablog.com

更新時のバージョン

OS X 10.10.3
Swift1.0

例文

Objective-C

[display setDoubleValue : [myOutlet doubleValue]];

Swift

    //NSControl doubleValue
    //Swift1.0
    var aButton003 : NSButton?
    var aTextField003 : NSTextField?
    func buttonAction003(sender: AnyObject?){
        var theWindow : NSWindow = (sender as! NSButton).window!
        aTextField003?.doubleValue = 1234
    }
    @IBAction func method003(sender: AnyObject) {
        var aWindow : NSWindow
        = NSWindow(contentRect: NSMakeRect(0.0, 0.0, 300.0, 200.0),
            styleMask: NSTitledWindowMask
                | NSClosableWindowMask
                | NSMiniaturizableWindowMask
                | NSResizableWindowMask,
            backing: .Buffered,
            defer: false,
            screen: NSScreen.mainScreen())
        windowArray.addObject(aWindow) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄
        aWindow.center()//ウインドウをスクリーンの中心に
        aWindow.title = "ウインドウタイトル"//タイトル設定
        //NSButton
        var theButton : NSButton = NSButton(frame: NSMakeRect(50.0, 50.0, 100.0, 30.0))
        theButton.title = "Action"
        theButton.bezelStyle = NSBezelStyle.RoundedBezelStyle
        theButton.action = Selector("buttonAction003:")
        theButton.target = self
        theButton.setButtonType(.MomentaryLightButton)
        //.SwitchButton
        //.PushOnPushOffButton
        aWindow.contentView.addSubview(theButton)
        
        //NSTextField
        var theTextField : NSTextField = NSTextField(frame: NSMakeRect(50.0, 150.0, 100.0, 30.0))
        //theTextField.action = Selector("buttonAction003:")
        //theTextField.target = self
        aWindow.contentView.addSubview(theTextField)
        
        //実験ウインドウにUIパーツを渡す
        self.aButton003 = theButton    //ボタン
        self.aTextField003 = theTextField        //テキストフィールド
        
        //ウインドウの表示
        aWindow.orderFront(self)//前面に
        aWindow.makeKeyAndOrderFront(self)//表示
    }