0

I have a class method that looks like this:

+ (NSTimeInterval)calculateTimeDifferenceBetweenEventDate:(NSDate *)eventTime andEventTime:(NSDate *)eventDate {

    NSTimeInterval timeDifference = [eventTime timeIntervalSinceDate:eventDate];

    // If eventTime is earlier than eventDate, a negative number is returned
    // If eventTime is later than eventDate, a positive number is returned

    return timeDifference;
}

I use the method like this:

NSTimeInterval timeDifference = [Utilities calculateTimeDifferenceBetweenEventDate:reminder.date andEventTime:savedEventDate];

But for some reason every time I use this class method the returned value is 0. When I'm inside and debugging the method I see that timeDifference actually contains a legit number. But for some reason it will not be returned properly?

Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
  • May I ask what the point of this method is, since you're not doing anything but return the result of `timeIntervalSinceDate:`? Why not just use `timeIntervalSinceDate:`? – jscs Jul 24 '12 at 21:08
  • 1
    Also, your parameter names are weird: `...BetweenEvent` **Date** `:(NSDate *)event` **Time** and `andEvent` **Time** `:(NSDate *)event` **Date**. – jscs Jul 24 '12 at 21:09
  • It might seem a little superfluous to have a method like that since it doesn't do much :) But it helps me keep a library of methods and if in the future want to add some extra functionality I can do it just to that method. – Peter Warbo Jul 24 '12 at 21:55

0 Answers0