I have a dictionary with multiple dictionary data :
{
1455201094707 = {
};
1455201116404 = {
}:
1455201287530 = {
};
}
I have to add all these dictionaries to an array in swift. How to iterate dictionary as :
for let tempDict in dataDictionary
{
self.tempArray.addObject(tempDict)
}
Error "let pattern cannot appear nested in an already immutable context"
for tempDict in dataDictionary as! NSMutableDictionary
{
self.tempArray.addObject(tempDict)
}
Error : Argument type element(aka(key:AnyObject, value:AnyObject)) argument type does not conform to expected type anyobject
for tempDict in dataDictionary as! NSMutableDictionary
{
self.tempArray.addObject(tempDict as! AnyObject)
}
Error: Could not cast value of type '(Swift.AnyObject, Swift.AnyObject)' (0x1209dee18) to 'Swift.AnyObject' (0x11d57d018).
for tempDict in dataDictionary
{
self.tempArray.addObject(tempDict)
}
Error: Value of Type AnyObject has no member generator
Edit
I want the final array as :
(
{
1455201094707 = {
};
}
{
1455201116404 = {
}:
}
)
What is the correct way to implement this?
Any help will be appreciated.....
I have used code :
var tempArray:[NSDictionary] = []
for (key, value) in tempDict {
tempArray.append([key : value])
}
Error: value of type AnyObject does not conform to expected dictionary key type NSCopying
code :
let tempArray = tempDict.map({ [$0.0 : $0.1] })
Error : type of expression is ambiguous without more context