After I struggled with this for a while and read a lot of messages from people struggling with the same problem, I realized that the metatheme: Swift is struggling with βcomplexβ arrays and dictionaries. To help Xcode, I explicitly defined the type of the variable for all of my arrays and dictionaries, rather than letting Xcode figure it out. It made my problems go away.
Instead of Swift determining the type of the variable by writing the following line of code:
var myDictionary1 = ["Item":[1,2,3],"Thing":[4,5,6],"Weight":[7,8,9]]
I rewrote my variable declarations as follows:
var myDictionary2: [String:[Int]] = ["Item":[1,2,3],"Thing":[4,5,6],"Weight":[7,8,9]]
As an additional note, Xcode auto-complete shows myDictionary1 as [String: ArrayInt] and myDictionary2 as [String: [Int]].
Stemonner
source share