daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest May 16th, 2018 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class PetNotificationWrapper {
  2.     let notification: Notification!
  3.     init(notification: Notification) {
  4.         self.notification = notification
  5.     }
  6.    
  7.     var name: String {
  8.         guard let name = object(for: "name") as? String else { fatalError("name is nil") }
  9.         return name
  10.     }
  11.    
  12.     var type: String {
  13.         guard let type = object(for: "type") as? String else { fatalError("type is nil") }
  14.         return type
  15.     }
  16.    
  17.     var age: Int {
  18.         guard let age = object(for: "age") as? Int else { fatalError("age is nil") }
  19.         return age
  20.     }
  21.    
  22.     var isHungry: Bool {
  23.         guard let isHungry = object(for: "hungry") as? Bool else { fatalError("hungry is nil") }
  24.         return isHungry
  25.     }
  26.    
  27.     var isScared : Bool {
  28.         guard let isScared = object(for: "scared") as? Bool else { fatalError("scared is nil") }
  29.         return isScared
  30.     }
  31.    
  32.     func object(for key: String) -> Any? {
  33.         return notification.userInfo?[key]
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top