I am specifically using XIB
as my UIView
, and then a UIViewController
for the controller in between the (M)odel
and (V)iew
in MVC
design pattern, as recommended by Apple..
Should I just connect the first responder outlet to the button outlet in Interface Builder
or should I programmatically add it to the UIViewController
-based Swift
class which controls that XIB
view?
I guess business logic should go in the UIViewController (C)ontroller
class… but what about regular application logic? I guess add a target to a button would be considered logic.. but ‘(V)iew’ logic…
2
Answers
For specificity -->
MODEL
contains the business, application and data structure logic.The
Controller
can utilize internal functions, classes, structs as well as external 'service' or 'manager' classes to manipulate theMODEL
, which the view should have connected it to it, and thus updates from. Bingo :)I actually prefer to make the code targets inside XIB classes and make an output interface for the XIB then let the ViewController or whatever view conform to It. This help Make the reusable XIB much easier to use
If we depend on The Parent View to add the target methods, so every parent will use the XIB should make Its own method, and the Parent does not have the usage guidelines (Interface), So It would lead to Inconsistency and debugging difficulty