According to this article I should be able to simply += two NSTimeIntervals together... but I can't. I'm trying to handle hitting 'pause' on a stop watch and being able to continue by using a 'running counter' so to speak of an NSTimeInterval called totalDuration. But when I do the following

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

I get:

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

baffled...

有帮助吗?

解决方案

Your totalDuration variable isn't declared as an NSTimeInterval; it's declared as a pointer to an NSTimeInterval (NSTimeInterval *). Drop the asterisk in the declaration for totalDuration and you should be good.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top