This strange behavior baffles me. I intend to create a dictionary with a single array field. Then within this array, two extra sub dictionaries are appended. Here is code,
var dictionary = [String: Any]()
var array = [[String: Any]]()
dictionary["array"] = array
var dict1:[String:Any] = ["abc": 123, "def": true]
var dict2:[String:Any] = ["111": 1.2345, "222": "hello"]
array.append(dict1)
array.append(dict2)
As you can see from the debugger output, the var array is updated successfully (with 2 sub dictionaries appended). But the dictionary["array"]
still has 0 value.
It appears the (dictionary["array"]
) and (array
) are two separate objects