Convert __NSCFNumber to Int32 Swift

I have a database at Parse.com and one of the columns is of type Number. When I pull data from Parse, I am given an error that I cannot convert __NSCFNumber to Int32.

var index = word["index"] as! Int32

      

I can't find any solution anywhere, could someone tell me what would be the correct way to convert the __NSCFNumber to Int32 type?

Thank!

+3


source to share


1 answer


__NSCFNumber

is a subclass NSNumber

. To get an integer from NSNumber

, you have to use its property integerValue

:



var index: Int32 = word["index"].integerValue

      

+6


source







All Articles