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?

exception shown in xcode

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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -