refactor: Add extension to Dictionary to simplify values retrieve
This commit is contained in:
+3
-6
@@ -62,10 +62,7 @@ class AlertsSeismicNotificationExpandedTableViewCell: EQNBaseTableViewCell, MKMa
|
||||
let aps = notification["aps"] as? [String: Any],
|
||||
let alert = aps["alert"] as? [String: Any] else { return }
|
||||
|
||||
var intensity = -1
|
||||
if let intensityString = notification["intensity"] as? String, let anIntensity = Int(intensityString) {
|
||||
intensity = anIntensity
|
||||
}
|
||||
let intensity = notification.eqn_intValue(for: "intensity") ?? 0
|
||||
containerView.backgroundColor = color(for: intensity)
|
||||
|
||||
if let title = alert["loc-key"] as? String, let args = alert["loc-args"] as? [String], let arg = args.first {
|
||||
@@ -74,8 +71,8 @@ class AlertsSeismicNotificationExpandedTableViewCell: EQNBaseTableViewCell, MKMa
|
||||
|
||||
// get coordinate
|
||||
var coordinate: CLLocation?
|
||||
if let latitudeString = notification["latitude"] as? String, let latitude = Double(latitudeString),
|
||||
let longitudeString = notification["longitude"] as? String, let longitude = Double(longitudeString) {
|
||||
if let latitude = notification.eqn_doubleValue(for: "latitude"),
|
||||
let longitude = notification.eqn_doubleValue(for: "longitude") {
|
||||
|
||||
coordinate = CLLocation(latitude: latitude, longitude: longitude)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user