How do I append one Dictionary
to another Dictionary
using Swift
?
I am using the AlamoFire
library to send a JSON
to a REST server
.
Dictionary 1
var dict1: [String: AnyObject] = [
kFacebook: [
kToken: token
]
]
Dictionary 2
var dict2: [String: AnyObject] = [
kRequest: [
kTargetUserId: userId
]
]
How do I combine the two dictionaries to make a new dictionary as shown below?
let parameters: [String: AnyObject] = [
kFacebook: [
kToken: token
],
kRequest: [
kTargetUserId: userId
]
]
I have tried dict1 += dict2
but got a compile error:
Binary operator '+=' cannot be applied to two '[String : AnyObject]' operands
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…