taku_oka
taku_oka

Reputation: 453

Creating a "Array" of "Dictionary" in Swift

var numDict = [String: Int]()
numDict = ["age": 2, "total": 3]

var numArray = [Int]()
numArray = [1,2,3,4]

var dictArray = [Dictionary]()  // Error: "Missing argument for parameter #1 in call"

the last line cause Error.

How should I Create Array of Dictionary?

Upvotes: 2

Views: 4035

Answers (1)

drewag
drewag

Reputation: 94683

You need to define the types for the dictionary inside the array:

var dictArray = [[String:Int]]()

In long form this would be:

var dictArray = Array<Dictionary<String,Int>>()

Upvotes: 4

Related Questions