© Bear Cahill 2021
B. CahillUI Design for iOS App Developmenthttps://doi.org/10.1007/978-1-4842-6449-2_13

13. Target/Action in SwiftUI

Bear Cahill1  
(1)
Denton, TX, USA
 

In the previous chapter, we used a Coordinator as our delegate for a UITextView. But we also realized the coordinator setup is just a helpful mechanism.

We could have made a new class for the delegate. Or we could have made the coordinate implement more protocols. The class we named Coordinate could have been named something else. I can inherit from another class and can implement what we need.

So can we use this same mechanism for the target/action pattern? Yes.

If you have an existing UIView, we’ve already seen you can use it with the UIViewRepresentable protocol. Declare its properties ...

Get UI Design for iOS App Development: Using SwiftUI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.