Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
IOS ESSENTIALS
Lecture 04
Jonathan R. Engelsma, Ph.D.
TOPICS
• Model / View / Controller
• Understanding
ViewControllers and their
life cycle.
• Overview of commonly
used iOSVi...
MODEL/VIEW/CONTROLLER
Model
Controller
View
Our iOS code is broken up into 3 different components
(Inspired by Paul Hegart...
MODEL/VIEW/CONTROLLER
Controller
View
The MODEL is the data our app produces/consumes.
Model
MODEL/VIEW/CONTROLLER
Model
Controller
The VIEW is what the user sees and interacts with on screen.
View
MODEL/VIEW/CONTROLLER
Model View
The CONTROLLER manages the model and the view.
Controller
MODEL/VIEW/CONTROLLER
Model
Controller
View
Controller can manipulate the model directly.
MODEL/VIEW/CONTROLLER
Model
Controller
View
Controller can manipulate the view directly.
Takes place via
an “outlet”
MODEL/VIEW/CONTROLLER
Model
Controller
View
Model /View should NEVER talk directly to each other!
MODEL/VIEW/CONTROLLER
Model
Controller
View
Views can sort of talk to controller, but only in a very controlled
manner!
Co...
MODEL/VIEW/CONTROLLER
Model
Controller
View
Controller serves as theView’s delegate and data source via Protocols
D
elegat...
GREETING DEMO
DEMO!!
VIEW CONTROLLERS
• View controllers manage a screen’s view hierarchy and the
segues between view controllers.
• The “glue”...
VIEW CONTROLLER
LIFECYCLE
• Recall the methods generated when we created our first app:
override func viewDidLoad() {
super...
VIEW CONTROLLER LIFE
CYCLE
• Understanding the view controller life cycle allows us to
properly manage the controller’s mo...
View property
Accessed
View
exists?
loadView
Return view
loadView
overriden?
Run loadView
Storyboard?
Load from
storyboard...
VIEW CONTROLLER
METHODS
Method Name Description
viewDidLoad View has finished loading.
viewWillAppear View is about to appe...
UITabBarController UICollectionViewController UITableViewController
UINavigationController
LIFECYCLE & STOPWATCH
DEMOS
DEMO!!
Upcoming SlideShare
Loading in …5
×

iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)

807 views

Published on

This lecture covers the essentials of the MVC architecture of iOS applications. The basic concepts are laid out, and then we apply them to several app examples.

The course is an intensive and very compressed deep dive into iOS development in Swift. Visit the course web page to get copies of the course outline, lecture notes, sample code, etc.

Course website: http://www.themobilemontage.com/2015/05/12/ios-bootcamp-learning-to-create-awesome-apps-on-ios-using-swift/

YouTube Link to lecture: TBD

Published in: Software
  • Be the first to comment

iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)

  1. 1. IOS ESSENTIALS Lecture 04 Jonathan R. Engelsma, Ph.D.
  2. 2. TOPICS • Model / View / Controller • Understanding ViewControllers and their life cycle. • Overview of commonly used iOSViewControllers
  3. 3. MODEL/VIEW/CONTROLLER Model Controller View Our iOS code is broken up into 3 different components (Inspired by Paul Hegarty’s very excellent MVC lecture.)
  4. 4. MODEL/VIEW/CONTROLLER Controller View The MODEL is the data our app produces/consumes. Model
  5. 5. MODEL/VIEW/CONTROLLER Model Controller The VIEW is what the user sees and interacts with on screen. View
  6. 6. MODEL/VIEW/CONTROLLER Model View The CONTROLLER manages the model and the view. Controller
  7. 7. MODEL/VIEW/CONTROLLER Model Controller View Controller can manipulate the model directly.
  8. 8. MODEL/VIEW/CONTROLLER Model Controller View Controller can manipulate the view directly. Takes place via an “outlet”
  9. 9. MODEL/VIEW/CONTROLLER Model Controller View Model /View should NEVER talk directly to each other!
  10. 10. MODEL/VIEW/CONTROLLER Model Controller View Views can sort of talk to controller, but only in a very controlled manner! Controller defines an action. View is wired up to call action.
  11. 11. MODEL/VIEW/CONTROLLER Model Controller View Controller serves as theView’s delegate and data source via Protocols D elegate Data Source
  12. 12. GREETING DEMO DEMO!!
  13. 13. VIEW CONTROLLERS • View controllers manage a screen’s view hierarchy and the segues between view controllers. • The “glue” between views and models in MVC. • View controllers: • initialize and setup models • populate the view hierarchy with views • coordinate with the view hierarchy (delegate) • format data for the views (data source)
  14. 14. VIEW CONTROLLER LIFECYCLE • Recall the methods generated when we created our first app: override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. self.configureView() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } • These are methods that help us coordinate with the controller’s lifecycle.
  15. 15. VIEW CONTROLLER LIFE CYCLE • Understanding the view controller life cycle allows us to properly manage the controller’s models and views. • Whenever a view controller’s view property is accessed a chain of events is triggered. https://developer.apple.com/library/IOS/featuredarticles/ViewControllerPGforiPhoneOS/ViewLoadingandUnloading/ViewLoadingandUnloading.html
  16. 16. View property Accessed View exists? loadView Return view loadView overriden? Run loadView Storyboard? Load from storyboard Empty View viewDidLoad Y Y Y N N N
  17. 17. VIEW CONTROLLER METHODS Method Name Description viewDidLoad View has finished loading. viewWillAppear View is about to appear. viewDidAppear View just appeared. viewWillDisappear View is about to disappear. viewDidDisappear View just disappeared didRecieveMemoryWarning Low memory conditions detected.
  18. 18. UITabBarController UICollectionViewController UITableViewController
  19. 19. UINavigationController
  20. 20. LIFECYCLE & STOPWATCH DEMOS DEMO!!

×