IOS Error "Initialization" NSTimeInterval * '(aka' double * ')

I'm trying to get the time interval between two NSDates, namely previousActivity.stopTimeand previousActivity.startTime. I get an error with this code:

NSTimeInterval *previousActivityDuration = [previousActivity.stopTime timeIntervalSinceDate:previousActivity.startTime];

This is where the error message appears:

"Initializing 'NSTimeInterval *' (aka 'double *') with an expression of incompatible type 'NSTimeInterval' (aka 'double')"

I do not understand; If NSTimeInterval aka 'double', how is the initialization expression incompatible and how to fix it?

Many thanks!

Edit:

In @Rmaddy's comment, I removed the asterisk. Then I get this error in the line following:

Assigning to 'NSNumber *' from incompatible type 'NSTimeInterval' (aka 'double')

Here's an offensive line:

previousActivity.duration = previousActivityDuration;
+4
source share
2 answers

- NSTimeInterval, , , - NSTimeInterval. , :

NSTimeInterval previousActivityDuration = [previousActivity.stopTime timeIntervalSinceDate:previousActivity.startTime];

, . Objective-C, , , , double ..

+10

, ,

NSTimeInterval *previousActivityDuration

to

NSTimeInterval previousActivityDuration

( )

cmd + NSTimeInterval, :

typedef double NSTimeInterval;

, , .

+4

Source: https://habr.com/ru/post/1525462/


All Articles