tags:

views:

159

answers:

2

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"]) { }

A: 

GetAsyncKeyState();

By standard console OI you can't do that.

oneat
A: 

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 (shouldChangeCharactersInRange:(NSRange)range) method. This is the code;

if ([[textField1.text stringByReplacingCharactersInRange:range withString:string] length]<[[textField1 text] length]) { //do nothing } else { //more programme code; }