What should be in view controllers and what should be in representations?

I am at the beginning of iOS app development. I find it difficult to understand the MVC (Model-View-Controller) design pattern. I thought I had it, but the more I read, the more confused I am. I don't know if this should be a specific issue for iOS or if it is suitable for any use of MVC. I do not use storyboards by the way, I want to do this all programmatically.

I believe that I understand the basic relationship between controllers and models, this separation of Views and Controllers, which I do not get. Let's say I want to create UIButtonand display it on the screen. Should I launch a button in a controller or in a view? The controller is responsible for what should be displayed, right? Could you just call View to display this and not worry about creating a button in the controller? From what I understand, View Controllers are just controllers and therefore should control the view, not the view. Most people seem to do almost everything in view controllers. I think my question comes down to which code goes where?

+3
source share
3 answers

UIViewController MVC .

  • M ()
  • (ontroller)
  • ()

..

: view viewcontroller

- , . (), . . , - .

, . . . . , . - . , .

- . , iOS , , . , . iOS , . , .

+1

- iOS, PHP , ( ), .

, .

, -, :

.

, .

0

, :

, UIViewControllers

, UIView

, NSObject

0

All Articles