我将从JSON解析的字典定义为[String:AnyObject]
然后我尝试访问它的值;
var vote: Int?
if let voteValue: AnyObject = dictionary["vote"] {
self.vote = voteValue as? Int
}
有更简单/更清洁的方法吗?
答案 0 :(得分:1)
只能想到:
var vote: Int?
vote = dictionary["vote"] as AnyObject? as? Int