Could not cast value of type '__NSCFNumber' (0x...) to 'NSString' (0x...).

The value is an NSNumber, not an NSString. You can use stringValue to convert it:

if let a = d["a"] as? NSNumber {
    let aString = a.stringValue
    println(aString) // -1
}

If you're sure it's there, you can use forced unwrapping and string interpolation:

let a = d["a"]! as! NSNumber
let aString = "\(a)"

你可能感兴趣的:(swift)