I have a button that toggles between Show/Hide mode (i.e. toggles a UITextField between secureTextEntry NO and YES). The purpose of which is to allow the user to see the password they are entering.

I followed the example (with the highest number of votes) here: [UITextField secureTextEntry - works going from YES to NO, but changing back to YES has no effect](https://stackoverflow.com/questions/6710019/uitextfield-securetextentry-works-going-from-yes-to-no-but-changing-back-to-y)

However, when I set secureTextEntry to NO, any text that was written there ends up with a space at the end. This does not seem to be a problem when setting secureTextEntry to YES. 

For example, if I enter the text "mypassword" while setSecureTextEntry is set to NO, and then switch it to YES, the user will see \*\*\*\*\*\*\*\*\*\* (10 dots), which is correct. If I setSecureTextEntry to NO, the user will see "mypassword " (with a space at the end, or at least, the cursor moved one space to the right). 

**Important note:** In the debugger, the string value of text appears **without** the trailing space, like this:

```
(lldb) expr self.passwordText.text
(NSString *) $0 = 0x1d8450e0 @"mypassword"

```

I have tried trimming whitespace (per [avoid middle whitespace in UITextField](https://stackoverflow.com/questions/4463496/avoid-middle-whitespace-in-uitextfield)), but it has had no effect.