Cs193 [top] Jun 2026
To implement this, we will create an extension for UITextField . This is "helpful" because it makes the feature available to text field in your app without rewriting code.
import UIKit
// Find the current View Controller in the Responder Chain if let viewController = self.findViewController() { let alert = UIAlertController(title: "Undo Typing", message: "Clear text field?", preferredStyle: .alert) To implement this, we will create an extension
If you want to make this feature truly production-ready (and learn about ), you shouldn't clear the text immediately. You should ask the user for confirmation.
This course, , is an introductory class for Computer Science and Data Science students at Purdue University . It focuses on the essential tools and technologies used in modern software development. You should ask the user for confirmation
In CS193, we often create subclasses to encapsulate behavior.
In your storyboard or code, change the class of your UITextField to ShakeableTextField . In CS193, we often create subclasses to encapsulate behavior
// Helper to traverse the responder chain to find the VC func findViewController() -> UIViewController? { var responder: UIResponder? = self while let next = responder?.next { if let vc = next as? UIViewController { return vc } responder = next } return nil } }

(48 votes, average: 4,60 out of 5)