我需要存储的当前数据是这样的
var dictData = [String: [String]] ()
[groupIdKey : [key1,key2], groupIdKey2 : [key3,key4] ]
如何将[key1,key2]插入特定的字典键,以及如何访问该dictData变量中的每个键?
我正在使用Firebase
数据库,这是我的代码
let groupId = self.defaults.stringArray(forKey: Constants.localDataKeys.localDataGroupId)
var addValueDict = [String: [Any]]() as NSDictionary
for group in groupId! {
geoLocRef.child("Group").child("\(group)").child("groupMembers").observeSingleEvent(of: .value, with: { (snapshot) in
if(snapshot.value as? [String: AnyObject]) == nil {
print("Gada group *geolocation*")
} else {
let memberIdDict = snapshot.value as! [String: Any]
let getGroupMemberId = Array(memberIdDict.keys)
// addValueDict["\(group)"]?.append([getGroupMemberId]) <-- My Error
}
})
} // end for loop NSUserDefaults