Ulrik. S Ulrik. S - 9 months ago 36
Swift Question

How to check a value is inside nested dictionary swift

I have a problem concerning my nested dictionary.

var level1Dictionary = [String : [String : String]]()
var ChosenDeckLabel = [String]

I want to see if the dictionary contains a certain value within my,
else if
statement as such:

else if level1Dictionary[ChosenDeckLabel[textview.text]] != nil {

this returns error:

Cannot subscript value of type String with an index of type String!

How should I cast it to check if the nested dictionary contains the value?


I think this is what you intend to do:

else if level1Dictionary[strIndex1][strIndex2] != nil {