English subtitles

← Passing Data Between ViewControllers - UIKit Fundamentals

Get Embed Code
3 Languages

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

  1. Now we've presented our
    DiceViewController in three different
  2. ways; programatically, using
    a combination of code and Storyboard,
  3. and entirely in Storyboard.
  4. Recall that in the first solution,
    the incoming instance of
  5. DiceViewController is
    manipulated directly.
  6. The current view controller has a chance
    to prepare the incoming view controller
  7. and what did that preparation involve?
  8. The roll view controller sets the two
    dice values on the dice view controller.
  9. When we use a segue the dice view
    controller never makes an appearance in
  10. our code because story board
    hides the creation of the object.
  11. So now we need a new hook to allow
    communication between the two view
  12. controllers.
  13. The method we need is
    called prepareForSegue.
  14. All view controllers
    inherit this method and
  15. it's invoked right before
    any segue is performed.
  16. Its entire purpose is to allow
    the current view controller to configure
  17. the incoming object.