user6631314 user6631314 - 21 days ago 6
iOS Question

IOS: NSDate dateWithTimeIntervalSinceNow

how would I use NSDate's dateTimeIntervalSinceNow method to calculate the difference between today and an NSDate sometime in the future?

The examples I have seen all take arguments such as the number of seconds:

NSDate *date = [NSDate dateWithTimeIntervalSinceNow:60*60*24*3];


I would like to perform the operation on another NSDate as in:

pseudocode

NSDate *date = NSDate dateWithTimeIntervalSinceNow:(NSDate*)futureDate];


Can anyone suggest best way to do this?

Thank you

Answer

As suggested by Dan in his comment, [futureDate timeIntervalSinceNow] accomplishes the task.

Comments