stanford cs193p
play

Stanford CS193p Developing Applications for iOS Spring 2016 CS193p - PowerPoint PPT Presentation

Stanford CS193p Developing Applications for iOS Spring 2016 CS193p Spring 2016 Today MVC Object-Oriented Design Pattern Continuation of Calculator Demo Computed Properties, MVC, Laying out the UI to work with different devices CS193p Spring


  1. Stanford CS193p Developing Applications for iOS Spring 2016 CS193p Spring 2016

  2. Today MVC Object-Oriented Design Pattern Continuation of Calculator Demo Computed Properties, MVC, Laying out the UI to work with different devices CS193p Spring 2016

  3. MVC Controller Model View Divide objects in your program into 3 “camps. ” CS193p Spring 2016

  4. MVC Controller Model View Model = What your application is (but not how it is displayed) CS193p Spring 2016

  5. MVC Controller Model View Controller = How your Model is presented to the user (UI logic) CS193p Spring 2016

  6. MVC Controller Model View View = Your Controller’ s minions CS193p Spring 2016

  7. MVC Controller Model View It’ s all about managing communication between camps CS193p Spring 2016

  8. MVC Controller Model View Controllers can always talk directly to their Model. CS193p Spring 2016

  9. MVC Controller outlet Model View Controllers can also talk directly to their View. CS193p Spring 2016

  10. MVC Controller outlet Model View The Model and View should never speak to each other. CS193p Spring 2016

  11. MVC Controller ? outlet Model View Can the View speak to its Controller? CS193p Spring 2016

  12. MVC Controller outlet Model View Sort of. Communication is “blind” and structured. CS193p Spring 2016

  13. MVC target Controller outlet Model View The Controller can drop a target on itself. CS193p Spring 2016

  14. MVC target action Controller outlet Model View Then hand out an action to the View. CS193p Spring 2016

  15. MVC target Controller outlet action Model View Then hand out an action to the View. CS193p Spring 2016

  16. MVC target Controller outlet action Model View The View sends the action when things happen in the UI. CS193p Spring 2016

  17. MVC target Controller outlet action should did will Model View Sometimes the View needs to synchronize with the Controller. CS193p Spring 2016

  18. MVC target should did will Controller outlet delegate action Model View The Controller sets itself as the View’ s delegate. CS193p Spring 2016

  19. MVC target should did will Controller outlet delegate action Model View The delegate is set via a protocol (i.e. it’ s “blind” to class). CS193p Spring 2016

  20. MVC target should did will Controller outlet delegate action Model View Views do not own the data they display. CS193p Spring 2016

  21. MVC target should did will Controller outlet delegate action Model View data count at So, if needed, they have a protocol to acquire it. CS193p Spring 2016

  22. MVC target should did will Controller outlet data count at delegate d a t a s action o u r c e Model View Controllers are almost always that data source (not Model!). CS193p Spring 2016

  23. MVC target should did will Controller outlet data count at delegate d a t a s action o u r c e Model View Controllers interpret/format Model information for the View. CS193p Spring 2016

  24. MVC target should did will Controller outlet data ? count at delegate d a t a s action o u r c e Model View Can the Model talk directly to the Controller? CS193p Spring 2016

  25. MVC target should did will Controller outlet data count at delegate d a t a s action o u r c e Model View No. The Model is (should be) UI independent. CS193p Spring 2016

  26. MVC target should did will Controller outlet data count at delegate d a t a s action o u r c e Model View So what if the Model has information to update or something? CS193p Spring 2016

  27. MVC target should did will Controller outlet data count at delegate Notification d a t a & KVO s action o u r c e Model View It uses a “radio station”-like broadcast mechanism. CS193p Spring 2016

  28. MVC target should did will Controller outlet data count at delegate Notification d a t a & KVO s action o u r c e Model View Controllers (or other Model) “tune in” to interesting stuff. CS193p Spring 2016

  29. MVC target should did will Controller outlet data count at delegate Notification d a t a & KVO s action o u r c e Model View A View might “tune in,” but probably not to a Model’ s “station. ” CS193p Spring 2016

  30. MVC target should did will Controller outlet data count at delegate Notification d a t a & KVO s action o u r c e Model View Now combine MVC groups to make complicated programs ... CS193p Spring 2016

  31. MVC target should did will Controller outlet data count at delegate Notification d a t a & KVO s action o u r c e Model View Now combine MVC groups to make complicated programs ... CS193p Spring 2016

  32. MVCs working together CS193p Spring 2016

  33. MVCs not working together CS193p Spring 2016

  34. Demo Calculator continued … “Computed” properties (instance variables which are computed rather than stored) switch Functions as types Closure syntax for defining functions “on the fly” UIStackView CS193p Spring 2016

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend