Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Objective challenge:
Q1) Pair off, and with a peer, each choose a design pattern and think of an instance you’ve used it code you’ve written or have seen it used in UIKit.
A1) We have used the MVC pattern in our beginning projects. We used this design pattern in our first build week project.
Objective challenge:
Q2)Look through the documentation and find at least one UIKit class that uses the singleton pattern.
A2) App Delegate
Objective challenge:
Q3) Think about a time we’ve used the facade pattern before. Are there places that we could have used it to write better code but didn’t? Discuss with a peer.
A3) Table View
Objective challenge:
Q4) Write code to post a notification when a button is tapped indicating a bell has rung. In another class, sign up to be notified when this notification is posted, and make sure it works.
A4) A “listener” that listens for notifications, called an observer
A “sender” that sends notifications when something happens
The notification center itself, that keeps track of observers and notifications
Here’s how you register an observer:
NotificationCenter.default.addObserver(self, selector: #selector(onDidReceiveData(_:)), name: .didReceiveData, object: nil)
Posting a notification: .didReceiveData, object: nil)
Objective challenge:
Add support for state restoration to another app you’ve built.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment