Search code examples
swiftxcodeappkit

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"){

   }
}

this said it didn't work or something now I want it to check if the password is like test and then it enters but now i tried to do it like the normal text box but it wouldn't work ether


Solution

  • Replace with

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