3

Is there an easy way for me to set a limit on the amount of characters my NSTextField can have? I don't want to have a counter then warn the user if it's over the limit, I want to set the limit so if it's past x characters that's it, they can't type anymore.

Matt S.
  • 13,305
  • 15
  • 73
  • 129

2 Answers2

3

Check out NSFormatter. It can help you do what you're looking for and a lot more. If you don't need something that complicated, you might try the NSTextField delegate methods.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
0

You could use Key-Value Validation to ensure the max. length is never exceeded.

This would allow you to additionaly notify the user if the entered length was too long - or you could just quietly modify the value.

cacau
  • 3,606
  • 3
  • 21
  • 42