Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PetNotificationWrapper {
- let notification: Notification!
- init(notification: Notification) {
- self.notification = notification
- }
- var name: String {
- guard let name = object(for: "name") as? String else { fatalError("name is nil") }
- return name
- }
- var type: String {
- guard let type = object(for: "type") as? String else { fatalError("type is nil") }
- return type
- }
- var age: Int {
- guard let age = object(for: "age") as? Int else { fatalError("age is nil") }
- return age
- }
- var isHungry: Bool {
- guard let isHungry = object(for: "hungry") as? Bool else { fatalError("hungry is nil") }
- return isHungry
- }
- var isScared : Bool {
- guard let isScared = object(for: "scared") as? Bool else { fatalError("scared is nil") }
- return isScared
- }
- func object(for key: String) -> Any? {
- return notification.userInfo?[key]
- }
- }
Add Comment
Please, Sign In to add comment