Вопрос

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