Ulrik. S Ulrik. S - 1 year ago 76
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?

Answer Source

I think this is what you intend to do:

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download