MyView only contains and displays a button that we are going to use to receive user input.

Getting User InputOur original problem was that we wanted to receive and respond to user input, but we didn’t want our View to intrude on the Controllers responsibilities, and vice versa.

We also want to keep from tightly coupling our two classes, in case we want to replace one of them later on.

What if we added the following functionality to MyView?public func setButtonAction(target: Any?, action: Selector) { self.

button.

addTarget(target, action: action, for: .

touchUpInside)}By doing so, we could call the following bit of code in MyController to set the appropriate response to a button tap:self.

typedView.

setButtonAction(target: self, action: #selector(respondToButtonTap(_:)))This is actually not a terrible solution compared to keeping all the View components in our Controller.

We may however run into some weird bugs if we connect several instances to receive signals from the button.

If any of those instances are deallocated, the selector will start looking for the next available object to receive that same signal, so the user input may end up making changes to another object than was originally intended.

To see what I mean, change the MyController class to the one below and see what happens when you hit the button:class MyController: BaseViewController<MyView> { private var counter: Int = 0 override func viewDidLoad() { self.

It would be a nightmare to hunt down a bug like this if it ever appeared in your code, especially since the Controllers that are initialized in viewDidLoad() are deallocated directly after the method returns.