I have read the documentation on the apple's developer website which refer following guidelines
- A view class shouldn't depend on a model class (although this may be unavoidable with some custom views).
- A view class shouldn't have to depend on a mediating controller class.
- A model class shouldn't depend on anything other than other model classes.
- A mediating controller class shouldn’t depend on a model class (although, like views, this may be necessary if it's a custom controller class).
- A mediating controller class shouldn't depend on view classes or on coordinating controller classes.
- A coordinating controller class depends on classes of all MVC role types.
Consider this scenario:
I have a view controller class called EmployeeViewController
.
I have some minor components of which are some are programmatically created and some are created through xib
.
What exactly I am doing is creating all the subviews inside the EmployeeViewController
class and adding them to the EmployeeViewController
's view, e.g. [self.view addSubView:…]
Is it a better option for me to create a seperate UIView
Subclass which consists of all the components and initialize it once and add it in the EmployeeViewController
?
What exactly is the correct way to implement MVC? Am I supposed to create separate components for view and controller or should I stack subviews inside the EmployeeViewController
?