简体   繁体   中英

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!

__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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM