joshim5
joshim5

Reputation: 2255

Is a pointer used with a NSTimeInterval?

Do you use a pointer with a NSTimeInterval even though it is defined to be an int?
For instance do you use: NSTimeInterval *time or NSTimeInterval time

Thank You!

Upvotes: 0

Views: 769

Answers (3)

zoul
zoul

Reputation: 104065

NSTimeInterval is a double, double-click the symbol while holding Cmd to see the typedef. Usually you will use it directly, but you can use a pointer for example to be able to change the value in a method call:

- (void) doSomethingLongAndReturnDuration: (NSTimeInterval*) duration
{
    CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
    …
    CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
    *duration = end-start;
}

This is a weird example, but you get the idea.

Upvotes: 2

Matt
Matt

Reputation: 4989

No, you don't generally need/use a pointer with NSTimeInterval, so NSTimeInterval time should be just fine.

Upvotes: 1

Max
Max

Reputation: 16719

NSTimeInterval is typedef to double. There is usually no reason to use pointer

Upvotes: 3

Related Questions