I like this quirk in quick (NOT).
This is one of the least intuitive mistakes in the language that I know of. Thus, it turns out that when you get a dictionary with the type AnyObject, Ints, Doubles, Floats, it is NOT stored as native Swift types. They are stored as ... a surprise! NSNumber.
This leads to a whole host of non-intuitive behaviors, for example to check the types of AnyObjects to see if you have Double or Int (this is not possible).
For the same reason, your code does not work. Change it to:
let ddd = oneJson["restaurantId"] as! Int print("ddd = \(ddd)") let restaurantId = (oneJson["restaurantId"] as? NSNumber)?.longLongValue
And again and again remind yourself that when you make AnyObject, Swift hides from you the fact that it throws from NSNumber for Swift's basic types, and in fact they are still just NSNumbers.
source share