stanford cs193p
play

Stanford CS193p Developing Applications for iOS Winter 2017 CS193p - PowerPoint PPT Presentation

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


  1. Stanford CS193p Developing Applications for iOS Winter 2017 CS193p Winter 2017

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

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

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

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

  6. MVC Controller Model View View = Your Controller’ s minions CS193p Winter 2017

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

  8. MVC Controller Model View Controllers can always talk directly to their Model. CS193p Winter 2017

  9. MVC Controller outlet Model View Controllers can also talk directly to their View. CS193p Winter 2017

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

  11. MVC Controller ? outlet Model View Can the View speak to its Controller? CS193p Winter 2017

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

  13. MVC target Controller outlet Model View The Controller can drop a target on itself. CS193p Winter 2017

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

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

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

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

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

  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 Winter 2017

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

  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 Winter 2017

  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 Winter 2017

  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 Winter 2017

  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 Winter 2017

  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 Winter 2017

  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 Winter 2017

  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 Winter 2017

  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 Winter 2017

  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 Winter 2017

  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 Winter 2017

  31. MVCs working together CS193p Winter 2017

  32. MVCs not working together CS193p Winter 2017

  33. Demo Calculator continued … MVC struct vs. class ( mutating , etc.) public versus private API more examples of Optional Dictionary<KeyType,ValueType> enum associated values switch Functions as types Closure syntax for defining functions “on the fly” UIStackView First peek at Autolayout (stick things to the edges) CS193p Winter 2017

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