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

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 cursor is) Then it … Read more

Detect backspace in empty UITextField

Swift 4: Subclass UITextField: // MyTextField.swift import UIKit protocol MyTextFieldDelegate: AnyObject { func textFieldDidDelete() } class MyTextField: UITextField { weak var myDelegate: MyTextFieldDelegate? override func deleteBackward() { super.deleteBackward() myDelegate?.textFieldDidDelete() } } Implementation: // ViewController.swift import UIKit class ViewController: UIViewController, MyTextFieldDelegate { override func viewDidLoad() { super.viewDidLoad() // initialize textField let input = MyTextField(frame: CGRect(x: 50, … Read more