Abu Eesa Abu Eesa - 17 days ago 7
Objective-C Question

Int64 can't be converted if store in Realm

I need to save 11 digits number in Realm, for that am using

Int64
.
When am reading it I need to convert it's datatype to
String


let icnStr = employeeObj["icn"] as! String


but it is showing following error.

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

Answer

Try String(employeeObj["icn"]), hope it help, dont downcast it but create String instance with value of the Int