标签:
extension Dictionary { /// 将字典合并到当前字典 //字典的分类法, 如果要使用 updateValue 需要明确的指定类型,范型函数 mutating func merge<K, V>(dict: [K: V]) { for (k, v) in dict { self.updateValue(v as! Value, forKey: k as! Key) }
//
updateValue
/// Update the value stored in the dictionary for the given key, or, if the
/// key does not exist, add a new key-value pair to the dictionary.
///
/// Returns the value that was replaced, or `nil` if a new key-value pair
/// was added.
}
//取出并且拼接 currentCls 的模型字典
使用 : infoDict.merge(modelInfo(currentCls))
标签:
原文地址:http://www.cnblogs.com/yaoyao0110/p/5533498.html