Reputation: 1205
I have a dictionary stored in a Plist that has an imbedded dictionary in it. If I use strings as the keys I can use the code below to cast it to a swift dictionary:
let namesDict = NSDictionary(contentsOfFile: path!)
var names = namesDict as [String: [String : String]]
However if I try to use integers as the keys in the root dictionary I can't get it to work. The code below doesn't work and returns this error: "value type is not bridged to Objective-C"
let namesDict = NSDictionary(contentsOfFile: path!)
var names = namesDict as [Int: [String : String]]
I have tried intValue, but that doesn't work either. What am I missing?
Upvotes: 1
Views: 411
Reputation: 15331
From Apple's NSDictionary reference:
In general, a key can be any object (provided that it conforms to the NSCopying protocol—see below), but note that when using key-value coding the key must be a string (see Key-Value Coding Fundamentals).
Plist are Key-Value coding compliant
Upvotes: 3