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:NSTimeInter开发者_如何学Goval *time
or
NSTimeInterval time
Thank You!
NSTimeInterval is typedef to double. There is usually no reason to use pointer
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.
No, you don't generally need/use a pointer with NSTimeInterval, so NSTimeInterval time
should be just fine.
精彩评论