English subtitles

← MVC - Intro to iOS App Development with Swift

Get Embed Code
3 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. At this point, I want to pause and connect the code that
  2. we've written thus far to an image we saw previously in the course.
  3. Here we tried to divide the different parts of our app into three camps.
  4. I also want to investigate our code and
  5. find out why is this programming file called ViewController?
  6. What do those words view and controller even mean?
  7. The place where this conversation starts is with an acronym.
  8. MVC, or model, view, and controller.
  9. And what this is, is a way to design or
  10. make software applications like the app that we are making.
  11. Let's begin with what is a view?
  12. Simply put, a view is what the user sees or
  13. is what is really visual on the screen.
  14. So in our case, that would be buttons like the microphone button and
  15. labels like the recording in progress label.
  16. If you look at the document outline, you will notice that the microphone button,
  17. the recording in progress label,
  18. the stop button, they all form a part of our view.
  19. To highlight the view on our screen, I can change its background color.
  20. I can simply slide out the utility area and change the background color.
  21. Boom.
  22. Done.
  23. Then let's think about the model.
  24. This refers to the data of our app.
  25. Now, we do not have one explicitly defined just yet.
  26. But when we record our audio in lesson four, that audio file, including the name
  27. of the file, the date it was recorded, that will all become a part of our model.
  28. And finally let's talk about the controller.
  29. A controller, as its name suggests,
  30. controls conversations between the model and the view.
  31. In our case, that is the ViewController.swift file.
  32. When a user presses on a button, like the microphone button,
  33. the controller handles that using an action.
  34. Also, when a controller wants to change something in a view, like show and
  35. hide this recording in progress label, it uses an outlet.
  36. Now, a valid question to ask at this point is, why do all of this?
  37. Well, the most important advantage is that we
  38. can separate the major components of our app.
  39. This helps in building large apps and
  40. in making changes to them at a later stage.