Skip to content

Instantly share code, notes, and snippets.

@drumnkyle
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drumnkyle/02b29e372ce1c919232c to your computer and use it in GitHub Desktop.
Save drumnkyle/02b29e372ce1c919232c to your computer and use it in GitHub Desktop.
Swift AnyObject Dictionary Problem
var nsDict: [NSObject : AnyObject] = ["test" : 4]
if let value = nsDict["test"] as? Int {
println("It is an Int")
}
// ERROR: 'Int' is not a subtype of '(NSObject, AnyObject)'
if let value = nsDict["test"].1 as? Int {
println("It is an Int")
}
// ERROR: Type 'DictionaryIndex<NSObject, AnyObject>' does not conform to protocol 'StringLiteralConvertible'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment