Lewis Black Lewis Black -4 years ago 132
Swift Question

How to initialise an array of empty arrays in swift?

My aim is to have an array of empty arrays in swift. Something like this:

[[][][][][]]


They are all of type Game. This is my attempt:

let numberOfDays = 5
var gamesCache: [[Game]] = [](count: numberOfDays, repeatedValue: [])


It comes up with the error. Cannot call value of non function type '[Any]'

Answer Source

Try like this way.

let numberOfDays = 5
var gamesCache = [[Game]](count: numberOfDays, repeatedValue: [])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download