I'm confused pattern MVC

Hello everyone I'm new in swift.

I have attached a picture to describe my reasoning on MVC pattern.

I would like to ask you some questions about the model:

1) The model can contain methods validation of input fields?

2) The model can contain bisness logic for access to a database?

3) the model may contain a mix of both of my questions?

I also thought about a solution but I'm not sure this is correct ..

The controller called a classa Delegate (where I write all the logic inside) the Delegate calls the Model class (specialized only for CRUD operations insert, delete and c ...)

link image

Thanks for all your help.




The Model-View-Controller design pattern is a guideline, and sometimes a model class might take on some controller aspects too.


If you haven't read through Apple's description of MVC:

https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaEncyclopedia/Model-View-Controller/Model-View-Controller.html#//apple_ref/doc/uid/TP40010810-CH14-SW1


The model often contains validation code, but it wouldn't interact directly with input fields in a view. The controller would be responsible for dealing with the input fields, and would either validate the input itself or call the right validation methods in the model.


It's definitely reasonable for a model class to contain the code for loading and saving itself to a database, but sometimes that functionality will be put in a seperate controller class, especially if multiple model objects are usually being loaded/saved to the database at the same time.

I'm confused pattern MVC
 
 
Q