Skip to content

Instantly share code, notes, and snippets.

@williamhqs
Last active July 5, 2017 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save williamhqs/30f55ab9f6fea94a7fd893ec9cd0beb1 to your computer and use it in GitHub Desktop.
Save williamhqs/30f55ab9f6fea94a7fd893ec9cd0beb1 to your computer and use it in GitHub Desktop.

View Layer Architecture

In a viewController usually there are many methods. In order make this part organized well. Here are the rules:

// MARK: - Life cycle

For viewDidLoad etc. methods about life cycle should in this part:

// MARK: - UI configuration methods

Only configure UI elements method: (This part could be refactored in the short future)

// MARK: - Actions and gestures

Actions and gestures

// MARK: - xxx Delegate methods

Delegate methods

//Ignore this: Common logic stuff should be in viewModel
@williamhqs
Copy link
Author

williamhqs commented Jul 5, 2017

example

class ViewController {
   //constants (comments are not needed)
   static let myConstants = 0
   ...
   //properties
   var property: String  = "hello"
   ...
   //IBOutLets
   @IBOutlet weak var view: UIView
   
   // MARK: - Life cycle
   
   // MARK: - UI configuration methods
   
   // MARK: - Actions and gestures
   
   // MARK: - xxx Delegate methods
   
   // MARK: - Private methods
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment