Last active
October 23, 2019 05:03
-
-
Save eliperkins/8f4115151497dc1953ea to your computer and use it in GitHub Desktop.
Revisions
-
eliperkins revised this gist
Oct 1, 2015 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ //: Mocks Playground import UIKit @@ -24,6 +24,8 @@ protocol PushNotificationRegistrar { func registerUserNotificationSettings(notificationSettings: UIUserNotificationSettings) } extension UIApplication: PushNotificationRegistrar { } class FauxRegistrar: PushNotificationRegistrar { var registered = false func registerUserNotificationSettings(notificationSettings: UIUserNotificationSettings) { @@ -35,4 +37,4 @@ var registrar = FauxRegistrar() var controller = PushNotificationController(registrar: registrar) controller.user = User() registrar.registered -
eliperkins created this gist
Oct 1, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ //: Playground - noun: a place where people can play import UIKit struct User { } struct PushNotificationController { let registrar: PushNotificationRegistrar init(registrar: PushNotificationRegistrar) { self.registrar = registrar } var user: User? { didSet { if let _ = user { registrar.registerUserNotificationSettings(UIUserNotificationSettings()) } } } } protocol PushNotificationRegistrar { func registerUserNotificationSettings(notificationSettings: UIUserNotificationSettings) } class FauxRegistrar: PushNotificationRegistrar { var registered = false func registerUserNotificationSettings(notificationSettings: UIUserNotificationSettings) { registered = true } } var registrar = FauxRegistrar() var controller = PushNotificationController(registrar: registrar) controller.user = User() registrar.registered // true