From the course: iOS Development: Architecture

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Display the message, part 2

Display the message, part 2

From the course: iOS Development: Architecture

Start my 1-month free trial

Display the message, part 2

- [Instructor] Here in the storyboard, I add a label to show the message, and make it stick in the middle of the screen using some constraints. To use the label, we need to create an outlet, so let's open up the view controller file and I'm gonna assign the outlet. Let's call it label. In the view controller, we need to subscribe to the message received event. I do that in the viewed load method. The notification names should be message received. The object can be near so that you don't limit the sender to any particular object. The queue can be the main queue, and finally comes the completion block. This block gets invoked whenever the app delegate sends a notification. It takes a single argument, that notification. I extract the message from the notification. It should be a string. And then we send the message to the label's text. And I'm gonna remove percent encoding to ensure that the text doesn't contain URL encoded characters. Now, I build and run both apps to install the…

Contents