backspace

The “backspace” escape character '\\b': unexpected behavior?

懵懂的女人 提交于 2019-11-26 03:47:36
So I'm finally reading through K&R , and I learned something within the first few pages, that there is a backspace escape character, \b . So I go to test it out, and there is some very odd behavior: #include <stdio.h> main () { printf("hello worl\b\bd\n"); } The output is hello wodl Can anyone explain this? Your result will vary depending on what kind of terminal or console program you're on, but yes, on most \b is a nondestructive backspace. It moves the cursor backward, but doesn't erase what's there. So for the hello worl part, the code outputs hello worl ^ ...(where ^ shows where the

Detect backspace in empty UITextField

让人想犯罪 __ 提交于 2019-11-26 03:16:38
问题 Is there any way to detect when the Backspace / Delete key is pressed in the iPhone keyboard on a UITextField that is empty? I want to know when Backspace is pressed only if the UITextField is empty. Based on the suggestion from @Alex Reynolds in a comment, I\'ve added the following code while creating my text field: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleTextFieldChanged:) name:UITextFieldTextDidChangeNotification object:searchTextField]; This