Objective-C - 类方法中的NSTimeInterval返回0

时间:2012-07-24 20:56:44

标签: objective-c return-value nstimeinterval

我有一个看起来像这样的类方法:

+ (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;
}

我使用这样的方法:

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

但由于某些原因,每次我使用这个类方法时返回的值都是0.当我在里面并调试方法时,我看到timeDifference实际上包含一个合法的数字。但由于某种原因它不会被正确归还?

0 个答案:

没有答案