7.1. App 7

We will build the following app in this module.

Here,

  • The first screen contains a button to fetch text from the second screen.

  • If the user taps the button, it takes the user to the second screen.

  • The second screen contains a TextField where a user can put some text. This screen also contains a button.

  • If the user puts some text and taps the button, it returns to the first screen, and the user will see the text on the first screen.

  • So, we have to send the text back to the first screen from the second screen. We will use the Notification Center to do that.

  • The first screen will observe the text, and the second screen will post updates to the text.

Creating a new app, App7

Now, let's create a new app in Xcode and name it 'App7.' Add the views and controllers of two screens:

First Screen:

FirstScreenView.swift

ViewController.swift

Second Screen:

SecondScreenView.swift

SecondScreenViewController.swift

Last updated

Was this helpful?