I have a question about how UIKit expects us to handle interaction events at scale.
From what I understand so far:
- For UIControls (UIButton, UISwitch, UITextField, etc.), we explicitly register with addTarget(_:action:for:).
- For gestures, we add UIGestureRecognizer instances to views.
- For UIView subclasses, we can override touch methods like touchesBegan/touchesEnded.
All of this must be done on the main thread, since UIKit isn’t thread-safe.
Now here’s my main concern
If I have a complex UI with hundreds or thousands of widgets, am I expected to perform these registrations individually for each widget and each high-level event (tap, long press, editing changed, etc.)?
Or does UIKit provide a more centralized mechanism?
In short: Is per-widget, per-event registration the “normal” UIKit approach, or are there best practices for scaling event handling without writing thousands of addTarget or addGestureRecognizer calls?
Thanks!