Objective-C is said to accept "\b" as the special character for backspace, how can I capture this in program?
My purpose is to catch it in an if-statement to enable me screen characters for my textField:
if ([someCharacter isEqualToString:@"\b"]) { }
I decided to forget to capture the backspace character itself, I programmatically captured the state by comparing the lengths of the string before and after the character placing action of the textField:shouldChangeCharactersInRange:replacementString:
method. This is the code:
if ([[textField1.text stringByReplacingCharactersInRange:range withString:string] length] < textField1.text.length)
{
//do nothing
}
else
{
//more programme code;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With