How to convert NSInteger to NSTimeInterval

I have slideTimerone that is NSInteger, and I want to convert it to NSTimeInterval.

I tried like this:

 NSTimeInterval slider = (NSTimeInterval)slideTimer;

but it does not work. Any idea?

+5
source share
2 answers

NSTimeInterval:

typedef double NSTimeInterval;

This code:

int i = 1500;
NSTimeInterval interval = i;
NSLog(@"%d", (int)interval);

Outputs:

2011-11-07 07:47:05.579 Craplet[7608:707] 1500

BTW, in Xcode 4.2, hold down the control key, and Apple keys and types will have underscores. Click on it and you will see the definition.

+7
source

In Swift :

let x: NSTimeInterval = NSTimeInterval(Int(123))
+4
source

All Articles