0

根据这篇文章 ,我应该能够简单地将 += 两个 NSTimeIntervals 放在一起......但我不能。我正在尝试处理在秒表上点击“暂停”并能够通过使用“运行计数器”来继续,可以说是一个名为 totalDuration 的 NSTimeInterval。但是当我执行以下操作时

NSDate *currentDate = [NSDate date];
NSTimeInterval timeInterval = [currentDate timeIntervalSinceDate:startDate];
// Add the saved interval
totalDuration += timeInterval;

我得到:

.../Views/bdNewTrackViewController.m:506:19: Invalid operands to binary expression ('NSTimeInterval *' (aka 'double *') and 'NSTimeInterval' (aka 'double'))

莫名其妙……

4

1 回答 1

6

您的totalDuration变量未声明为NSTimeInterval; 它被声明为指向NSTimeInterval( NSTimeInterval *) 的指针。去掉声明中的星号,totalDuration你应该会很好。

于 2013-10-14T02:33:26.780 回答