Objective c iOS:为什么可以';我不能把两个时间间隔加在一起吗?
我应该能够简单地+=两个NSTimeInterval在一起。。。但我不能。 我正在尝试处理在秒表上点击“暂停”,并能够通过使用“运行计数器”继续,也就是说一个名为totalDuration的NSTimeInterval。 但当我做以下事情时Objective c iOS:为什么可以';我不能把两个时间间隔加在一起吗?,objective-c,nstimer,nstimeinterval,Objective C,Nstimer,Nstimeinterval,我应该能够简单地+=两个NSTimeInterval在一起。。。但我不能。 我正在尝试处理在秒表上点击“暂停”,并能够通过使用“运行计数器”继续,也就是说一个名为totalDuration的NSTimeInterval。 但当我做以下事情时 NSDate *currentDate = [NSDate date]; NSTimeInterval timeInterval = [currentDate timeIntervalSinceDate:startDate]; // Add the save
NSDate *currentDate = [NSDate date];
NSTimeInterval timeInterval = [currentDate timeIntervalSinceDate:startDate];
// Add the saved interval
totalDuration += timeInterval;
我得到:
../Views/bdNewTrackViewController.m:506:19:二进制表达式('NSTimeInterval*'(也称为'double*')和'NSTimeInterval'(也称为'double')的操作数无效。
困惑…您的
totalDuration
变量未声明为NSTimeInterval
;它被声明为指向NSTimeInterval
(NSTimeInterval*
)的指针。在声明中为totalDuration
删除星号,您应该是好的。您的totalDuration
变量未声明为NSTimeInterval
;它被声明为指向NSTimeInterval
(NSTimeInterval*
)的指针。在声明中为totalDuration
删除星号,您应该很好。这里的totalDuration数据类型是什么?这里的totalDuration数据类型是什么??