-
Peter J. Keleher authoredPeter J. Keleher authored
We have built a very small example app that contains first FirstController
and SecondController
class definitions defined in a single file. The files are setup for a simple example in use of navigation controllers and delegation. You need to write the code to make this work. See demo:
If the following movie doesn't play for you, click on the navPre.mp4 file above
The way this is intended to work is:
- The FirstController has a label that says "nothing yet".
- Clicking on "Second":
- segues to the SecondController, which has a textField.
- and the
FirstController
must TELL theSecondController
to specify "Change Me!" as the initial value of it'sTextField
.
- When the user hits the "Back" nav button:
- the
SecondController
informs theFirstController
of theTextField
's new value - which the
FirstController
sets as it's label's new value.
- the
It's unorthodox, but we want you to write all the code for two controllers together in the supplied box (the "ViewController.swift" file).
You may work on this question in Xcode.
Enter the full text of your ViewController.swift
file (containing the full definitions of both controller types,
plus anything else you need to define) in the answer field on GradeScope.
And yes, this should compile and run correctly when we cut and paste into our version of the project.
Hints:
- you will need to prepare() for the segue.
- a delegate protocol should be involved in returning the value back to the FirstController.