I am trying to keep to the Apple MVC design pattern where the view receives input and passes it on to the controller. To keep the controller thin and to avoid it turning into a bloated GodClass
doing all the work, I am attempting to create a subclass of UIView
and to receive user input there to be passed to the controller for processing. But I am running into problems with how to best do this in Swift.
In order to pass the user input from the view to the controller my UIView
subclass will need to communicate with the associated ViewController
, but I've seen posts on SO about how that is not recommended. This Q&A, for example, advises that this is bad but suggests a delegate approach. A comment from the same Q&A also notes that this is bad.
Apple's own MVC example doesn't demonstrate a separate UIView
subclass, but uses the existing UITableView
, which is all coded within the parent UIViewController
, making it a bloated, rather than a thin controller.
How to best approach this?