I am from web background and have majorly worked on MVC, so please excuse me if my question sound trivial.
To get rid of Massive View Controller in iOS, I could see two possibilities (from many others) like MVP or breaking 'Massive Controller' into two controller-
-
Breaking controller into two
-
View Controller (regular iOS controller) - This will be close to view and handle all the presentation logic.
-
Model Controller - This controller will handle all the interaction with Application/Data provider class. View Controller would have its reference and will call ModelController's method in case of any event. ModelController would not have any reference to ViewController.
-
-
And if I introduce MVP in iOS, my controller and presenter would talk to each other through interface (protocol in swift). In this case, communication from view controller to Presenter would be through event handling. And from Presenter to ViewController, would be done by calling ViewController API's.
Looking at both the approach, approach 1 seems to be less complicated (since there is one way communication from viewController to modelController, and that through API), where as MVP seems bit overcomplicated.
What extra benefits one would get by using 2nd approach over 1st? Please let me know my there are gaps in my understanding.
Thanks In Advance
Aucun commentaire:
Enregistrer un commentaire