Reputation: 1029
This is not a duplicate of the question
Cannot subscript a value of type '[NSObject : AnyObject]?' with an index of type 'String'
or
Cannot subscript a value of type '[String : String]?' with an index of type 'String'
The reason is because my dictionary is not optional, which was the problem with that question. Why is it that I can't subscript this...
Upvotes: 1
Views: 803
Reputation: 42143
Accessing dictionaries with a subscript always returns an optional. This is because you can't tell the dictionary that your are always going to use a subscript that exists in the keys list. (even if you could, it wouldn't believe you :).
Upvotes: 0