= notification.userInfo else { return } if let id = userInfo["id"] as? Int, let name = userInfo["nickname"] as? String { print(id) print(name) } else if let token = userInfo["token"] as? String { print(token) } }
= notification.userInfo else { return } if let id = userInfo["id"] as? Int, let name = userInfo["nickname"] as? String { print(id) print(name) } else if let token = userInfo["token"] as? String { print(token) } } ΩʔΛࣗྗͰ֮͑Δඞཁ͕͋Δ ಛఆͳܕʹΩϟετμϯ͢Δඞཁ͕͋Δ if จཏͰ͖Δอূ͕ͳ͍
nickname: String) case anonymous(token: String) } } extension Notification.Player { static let key = "Player" } guard let player = notification .userInfo?[Notification.Player.key] as? Notification.Player else { return } switch player { case .normal(id: let id, nickname: let name): print(id) print(name) case .anonymous(token: let token): print(token) } ΩʔΛ֮͑Δඞཁ͕ͳ͍ ܕΛΩϟετμϯ͢Δඞཁ͕ͳ͍ switch case จʹΑΔཏੑͷอূ