我想获取我的语言环境通知的userinfo。 我是这样做的:
var app:UIApplication = UIApplication.sharedApplication()
for oneEvent in app.scheduledLocalNotifications {
var notification = oneEvent as! UILocalNotification
ate = gregorian.dateFromComponents(comps)!
var OldUUID = notification.userInfo
}
}
结果是:
{UUID = WhmMbGrCkJ;}"
但我只想要这个部分:WhmMbGrCkJ 我尝试这样的事情:
var OldUUID = notification.userInfo
var OldUUIDSplit = OldUUID.componentsSeparatedByString("=")
var OldUUIDSplit2 = OldUUIDSplit[1].stringByReplacingOccurrencesOfString(" ", withString: "")
var OldUUIDSplit3 = OldUUIDSplit2.componentsSeparatedByString(";")
var NewOldUUID = OldUUIDSplit3[0]
我收到此错误:
无法调用' componentsSeparatedByString'使用类型'(字符串)'
的参数列表
我该如何解决?
答案 0 :(得分:1)
这应该可以胜任。 userInfo只是一个字典,因此您可以按键获取值:
if let dict = notification.userInfo, OldUUID = dict["UUID"] {
println("\(OldUUID)")
}