skip to Main Content

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


  1. Chosen as BEST ANSWER

    User should use a controller, which has view attached, to manipulate data model and update the view of the controller they are using, which is attached. This makes the most sense to me.

    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 the MODEL, which the view should have connected it to it, and thus updates from. Bingo :)


  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search