Trouble with NSTextField in Swift using xcode 6.1 (OSX)

前端 未结 1 1904
孤街浪徒
孤街浪徒 2021-01-29 07:26

I started Swift but not Objective C. Can someone teach me how to get and set the NSTextField in Swift using xcode 6.1 under OSX?

1条回答
  •  执笔经年
    2021-01-29 07:38

    You get and set the value of an NSTextField with the stringValue property. For instance, if you have this @IBOutlet in your app:

    @IBOutlet weak var textfield: NSTextField!
    

    getting the value:

    println("textfield is \(textfield.stringValue)")
    

    setting the value:

    textfield.stringValue = "this is my string"
    

    0 讨论(0)
提交回复
热议问题