xcode 安全文本字段如何获取在那里输入的密码?

xcode secure text field how to get the password typed in there?

@IBOutlet weak var button: NSButton!
@IBOutlet weak var password: NSSecureTextField!
@IBAction func buttonclick(_ sender: Any) {
   if(password.text == "test"){

   }
}

这说它不起作用什么的 现在我想让它检查密码是否像测试然后输入 但现在我试着像普通文本框那样做,但它不起作用 ether

替换为

if password.stringValue == "test" {
        print("correct")
    }