Module Outline
Use the following resources and work with your mentor to master the objectives for this module. Practice by completing the Mini-Project, Project, and Challenges.
Objectives
- You will be able to identify, display, and respond to user responses from an Alert Controller
- You will be able to instantiate, schedule, and handle Local Notifications
Comunicate with user using UIAlertViewController and schedule a device notification in the future with Local Notifications
Required Preclass Resources
-
UIAlertController Documentation
Pay attention to the closure syntax for setting up UIAlertActions.
-
UILocalNotification Documentation
Look for what is required to schedule a local notification.
-
UIAppDelegate Documentation
Pay attention to how we respond to UILocalNotifications in the App Delegate.
Lesson Video
Preclass Videos
- iOS5 Cohort - Bryan Bryce
-
iOS Cohort - Jake Gundersen
Local Notifications
- iOS3 Cohort - Taylor Mott
Video Challenges
-
Random Assignment
Update the 3 Card Monte game to randomize the Queen.
-
Reminder
Build a view with a text field and a 'Schedule Reminder' button. When the user enters text and presses the button, schedule a reminder using that text to fire in 10 seconds. Remember to request permissions and address receiving local notifications while the app is active.
Stretch Problem
- Create a
protocol Vehicle
that requires a variable for speed as aDouble
, a variable for isMoving as aBool
, and afunc startMoving()
andfunc stopMoving()
. - Create two separate classes that conform to the
Vehicle
protocol (i.e.class LawnMower
andclass Truck
). Your start and stop functions should simply check for whether or not the isMoving property is true or false, switch it to the opposite, and then print whether or not it is moving. - Create one instance of each of your two classes, and call your start and stop functions on them to be sure they work.
- Notice that you have to write the same function in two distinct classes. Create an extension on your vehicle protocol and implement the two functions there. Now delete the two functions from your two classes. Notice that you do not have an error and that the functions still work.
- Create a
protocol Racer
that inherits from your first protocol and adds afunc race() -> Double
. - Implement your race function in a protocol extension. It should return the time it takes for the vehicle the function was called on to travel 1000 meters.
- Create two more classes that conform to
Racer
or make your existing vehicles conform toRacer
. Create another function outside of your classes that will take in twoRacer
objects and return the winner. - Solution
Protocols and Protocol Extensions
♦ Black Diamond
Guided Project
PowerNapTimerWithAlerts
PowerNapTimer is designed to have students practice implementing timer logic, NSNotifications, UIAlertController, and UILocalNotifications.
Project
-
Alarm Part Two
Students will build a simple alarm app to practice intermediate table view features, protocols, the delegate pattern, NSCoding, UILocalNotifications, and UIAlertControllers.
ReadMe
Mastery Review
- Protocols and Protocol Extensions stretch problem
- Challenges
- Random Assignment objective challenge
- Reminder objective challenge
- PowerNapTimerWithAlerts guided project