Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSDate - Setting a future date

Facing some problem in setting up future date. Actually I m trying to do this,

NSDate *date = [NSDate date] + MY_EXTRA_TIME;
like image 771
JiteshW Avatar asked Oct 19 '11 04:10

JiteshW


2 Answers

That should be,

NSTimeInterval MY_EXTRA_TIME = 10; // 10 Seconds
NSDate *futureDate = [[NSDate date] dateByAddingTimeInterval:MY_EXTRA_TIME];
like image 104
EmptyStack Avatar answered Nov 11 '22 21:11

EmptyStack


Swift

let delay:NSTimeInterval = 5
let fireDate = NSDate().dateByAddingTimeInterval(delay)
like image 21
SwiftArchitect Avatar answered Nov 11 '22 20:11

SwiftArchitect