6

I have a UITextField that has the "Secure Text Entry" checked in my storyboard.

When I assign the text of the UITextField.text property to a variable I get a value of:

class name = _NSClStr

instead of the actual value of the text which is:

ABCD

If I uncheck the "Secure Text Entry" in the storyboard and do the same assignment to a variable I get the actual text.

The code to assign the value is pretty simple:

passFieldText = self.passField.text!

The debugger output for when the secure entry is enabled:

(lldb) print passFieldText
(String) $R0 = class name = _NSClStr

The debugger output for when secure entry is disabled:

(lldb) print passFieldText
(String) $R0 = "ABCD"

I even tried to use a local variable instead of a class variable:

let passFieldText = self.passField.text ?? ""

Same result!

(lldb) print passFieldText
(String) $R0 = class name = _NSClStr

The passFieldText is passed along to another function to validate the password and in that other function it also shows a value of class name = _NSClStr

What am I missing?

Cheers!

TJ Asher
  • 737
  • 9
  • 27
  • 1
    What happens when you write `print("password: \(passField.text ?? "")")`? The debugger does not always show the correct values. – Dominik 105 Aug 12 '20 at 19:33
  • Could you share some more of your code? I ran a quick test and it works as expected. Could you something with the way you have the UITextField setup. – TheAppMentor Aug 13 '20 at 16:06
  • So this is interesting/odd. If I put the print() in code I get the proper value I expect. If I print from the debug window I get the _NSClStr thing. – TJ Asher Aug 14 '20 at 18:55

2 Answers2

2

I had the same issue, the only way to fix it is to interpolate the String:

password = "\(self.passField.text)"

It's not exclusive for print()

0

So the cause of my problem was not the text from the password field. It turned out to be an issue with an external service.

However, to help anyone else to see the actual value of their password fields in code I'll share the suggestion by Dominik 105 and how I implemented it.

To see the value of the password field if I put the PRINT in code I see the actual value of the password field.

print("password1: \(self.passField.text ?? "")")

gives me the result I expect

ABCD

If I do the same PRINT in the debugger output I see the _NSClStr thing.

TJ Asher
  • 737
  • 9
  • 27