【发布时间】:2016-02-21 04:56:29
【问题描述】:
我编写了以下函数来访问 userInfo 字典:
func updateAddressLabel(notification: NSNotification) {
let userInfo:Dictionary<String,AnyObject> = notification.userInfo as! Dictionary<String, AnyObject>
self.infoLabelAddress.text = userInfo["geocodeLocation"]
}
func updateDispatchInformation(notification: NSNotification) {
let userInfo:Dictionary<String,AnyObject> = notification.userInfo as! Dictionary<String, AnyObject>
let streetName = userInfo["streetName"]
let incidentLatitude = userInfo["latitude"]
let incidentLongitude = userInfo["longitude"]
// Set Dispatch Info Label
self.infoLabelTitle.text = "Notruf"
self.infoLabelAddress.text = streetName
self.createIncidentAnnotation(incidentLatitude, longitude: incidentLongitude)
}
但我无法访问密钥,因为我收到错误:
不能用“String”类型的索引为“Dictionary String,AnyObject> 类型的值下标
【问题讨论】:
标签: swift nsdictionary