Search code examples
iphoneobjective-cnstimeinterval

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!


Solution

  • 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.