swift - EXC_BAD_INSTRUCTION only in iPhone 5 simulator -
running code on iphone 5 simulator throws exception shown in image. running code on of other simulators fine.
i can't spot made mistake in unspectacular line of code. else have problem?
nsinteger (which type alias int in swift) 32-bit integer on 32-bit platforms iphone 5. result of
nsinteger(nsdate().timeintervalsince1970) * 1000 is 1480106653342 (at moment) , not fit range -2^31 ... 2^31-1 of 32-bit (signed) integers. therefore swift aborts execution. (swift not "truncate" result of integer arithmetic operations done in other programming languages, unless use "overflow" operators &*.)
you can use int64 64-bit computations on all platforms:
int64(nsdate().timeintervalsince1970 * 1000) in case, if string needed:
let lastlogin = string(int64(nsdate().timeintervalsince1970 * 1000)) wiki

Comments
Post a Comment