Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert __NSCFNumber to Int32 Swift

I have a database setup on Parse.com, and one of the column has a type Number. When I pull the data from Parse, I'm given the error that I can't convert __NSCFNumber to Int32.

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

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

Thanks!

like image 449
Firyn Avatar asked Feb 09 '23 22:02

Firyn


1 Answers

__NSCFNumber is a subclass NSNumber. To get an integer out of an NSNumber, you would use its integerValue property:

var index: Int32 = word["index"].integerValue
like image 181
mipadi Avatar answered Feb 20 '23 20:02

mipadi