How do you set the text in an NSTextField?

前端 未结 7 2187
孤城傲影
孤城傲影 2020-12-08 12:39

I\'m trying to set the text in an NSTextField, but the -setStringValue: and -setTitleWithMnemonic: methods are not working. Any ideas?

相关标签:
7条回答
  • 2020-12-08 13:22

    Swift 4

    self.yourTextField.stringValue = "Your_Value"
    

    Note: Fetching value from self.yourTextField.stringValue at that will get warning message i.e. To avoid this kind of warning you can use like this (suggested way)

    DispatchQueue.main.async {
     your code ... 
    } 
    

    OR also refer to this.

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