【发布时间】:2017-02-05 15:28:47
【问题描述】:
我正在尝试获得“警报”的价值,但运气不佳。
LazyMapCollection<Dictionary<AnyHashable, Any>, AnyHashable>(_base: [AnyHashable("google.c.a.e"): 1, AnyHashable("google.c.a.ts"): 1475009164, AnyHashable("google.c.a.udt"): 0, AnyHashable("gcm.n.e"): 1, AnyHashable("aps"): {
alert = "test message";
}, AnyHashable("google.c.a.c_id"): 9039575328704479116, AnyHashable("gcm.message_id"): 0:1475009164740581%df6f7f01df6f7f01], _transform: (Function))
这是代码是一个使用,但它不能正常工作
if (userInfo["aps"] != nil) {
let msg = (userInfo["alert"] as? String)!
let alert1 = UIAlertController(title: "Notification", message: msg, preferredStyle: .alert)
alert1.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action) -> Void in
}))
self.window?.rootViewController?.present(alert1, animated: true, completion: nil)
completionHandler(.newData)
}
我正在尝试显示带有值警报消息的本地通知。任何想法,将不胜感激。谢谢
【问题讨论】:
-
“无法正常工作”是什么意思?它做了什么,你期望它做什么?这个
LazyMapCollection和它下面的代码有什么关系? -
我正在尝试在通知中显示“警报”的值,即“测试消息”。这行代码抛出异常 let msg = (userInfo["alert"] as?String)!
标签: swift dictionary collections lazy-evaluation