ios - Swift: '()' is not convertible to '[String : AnyObject]' -
i added custom extension
able combine 2 dictionaries
having problem method calling new extension.
dictionary extension defined in appdelegate
extension dictionary { mutating func merge<k, v>(dict: [k: v]){ (k, v) in dict { self.updatevalue(v value, forkey: k key) } } }
method using new extension
class func addfbtokenparameter(json: [string: anyobject]) -> [string: anyobject] { if keychainmanager.getstring(keychainmanager.staticvars.kfbtoken) != nil { allow token = keychainmanager.getstring(keychainmanager.staticvars.kfbtoken)! var tokenparams: [string: anyobject] = [ kfacebook: [ ktoken: token ] ] var finalparams: [string: anyobject] = tokenparams.merge(json) homecoming finalparams } else { homecoming json } }
i getting error on line:
var finalparams: [string: anyobject] = tokenparams.merge(json)
what error mean? , how right it?
thank you!
tokenparams.merge(json)
returning void
aka ()
. can prepare code by:
tokenparams.merge(json) var finalparams: [string: anyobject] = tokenparams
your extension need homecoming mutated dictionary assignable:
extension dictionary { mutating func merge<k, v>(dict: [k: v]) -> [k: v] { (k, v) in dict { self.updatevalue(v value, forkey: k key) } homecoming self } }
ios dictionary swift
No comments:
Post a Comment