将此数据作为通知返回,并希望将其读入可用的变量类型。我让他们所有人都工作,但奖励和应用程序
%@ [AnyHashable("description"): Open 10 common chests., AnyHashable("icon"): localhost:8000//media/achievements/Common%20Chest%20Go- Getter/bomb.jpg, AnyHashable("name"): Common Chest Go-Getter, AnyHashable("gcm.message_id"):1486597426811663%bf6da727bf. 6da727, AnyHashable("rewards"): {"Battle helm":1,"Gems":1000}, AnyHashable("aps"): {
alert = "Achievement Completed";
}]
那么如何将其转换为可用变量呢?
AnyHashable("rewards"): {"Battle helm":1,"Gems":1000}, AnyHashable("aps"): {
alert = "Achievement Completed";
}
返回的项目称为 userInfo 所以就像...
let rewards = userInfo["rewards"] as! [String:Int]
不起作用,对此的任何帮助将不胜感激!我再次使用 swift 3.0,所以 swift 3.0 示例可能会有所帮助。