Leem.fin
Leem.fin

Reputation: 42602

Convert long long value to NSTimerInterval

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

Answers (1)

trojanfoe
trojanfoe

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

Related Questions