Is a pointer used with a NSTimeInterval?

768 views Asked by At

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!

3

There are 3 answers

0
zoul On BEST ANSWER

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.

0
Max On

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

0
Matt On

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