Cocoa错误:类型为';NSButton';没有成员';setTitle';

Cocoa错误:类型为';NSButton';没有成员';setTitle';,cocoa,swift3,Cocoa,Swift3,在Swift3中,我有一个按钮声明如下: @IBOutlet weak var transmitButton: NSButton! 我正在尝试设置它的标题: func textViewDidChange(_ textView: NSTextView) { // If we're already transmitting, stop if transmitButton.state == NSOnState { transmitButto

在Swift3中,我有一个按钮声明如下:

 @IBOutlet  weak var transmitButton: NSButton!
我正在尝试设置它的标题:

func textViewDidChange(_ textView: NSTextView) {
        // If we're already transmitting, stop
        if transmitButton.state == NSOnState {
            transmitButton.setNextState()
            transmitButton.setTitle("On", for: .normal)
        }
    }
我得到一个错误:

Value of type 'NSButton' has no member 'setTitle'
如果有任何想法,我将不胜感激。

这是NS按钮没有
setTitle:for:
方法,如在UI按钮中,只有
title
属性:

transmitButton.title = "On"
这是NS按钮没有
setTitle:for:
方法(如UI按钮),只有
title
属性:

transmitButton.title = "On"

您只需设置标题,无需设置标题:
transmitButton.title=“On”
您只需设置标题,无需设置标题:
transmitButton.title=“On”
,这很简单。我撞了半个小时的头。非常感谢。总是建议查看文档(⌥- 或⌘-单击符号)或⇧⌘0或⇧⌘O然后键入
NSButton
。有很多方法,很简单。我撞了半个小时的头。非常感谢。总是建议查看文档(⌥- 或⌘-单击符号)或⇧⌘0或⇧⌘O然后键入
NSButton
。有很多方法。