Reputation: 42602
In my iOS project I received a long long
value which represents a value in milliseconds. I need to convert it to NSTimeInterval
. How can I convert this value to NSTimeInterval
?
I know NSTimeInterval
is a type of double
, but my value is a long long
type. I tried:
NSTimeInterval *time = longlongvalue / 1000.0;
but there is compiler error of imcompatible type, because NSTimeInterval
is a double
type, while my value is long long
.
Upvotes: 1
Views: 606
Reputation: 122391
NSTimeInterval
represents seconds, and assuming both values have the same epoch:
long long ms = 1234567890LL;
NSTimeInterval interval = ms / 1000.0;
// ^
// Remove *
Upvotes: 4