0

I'm building a Passcode Lock view, and I want to set the text to a dot on one of the four box labels when a user enters a new character into the text field.

Should I use textField:shouldChangeCharactersInRange:replacementString or UITextFieldTextDidChangeNotification?

Using textField:shouldChangeCharactersInRange:replacementString seems easier, but shouldChangeCharactersInRange seems more correct.

Community
  • 1
  • 1
ma11hew28
  • 121,420
  • 116
  • 450
  • 651

1 Answers1

1

I’d recommend using the delegate method, rather than the notification. Another option: set the text fields’ secureTextEntry property to YES. (See the documentation for the UITextInputTraits protocol, which UITextField conforms to).

David Cairns
  • 603
  • 5
  • 18