Search code examples
objective-cnslog

question concerning NSLog output %i, %d


I have question concerning a function I created. I would like to show the timeinterval in my console output.

-(void)MyTimeInterval:(id)sender
{
    NSDate *then = [NSDate date];

    NSDate *now = [NSDate date];

    NSTimeInterval interval = [now timeIntervalSinceDate:then];

    NSLog(@"let me see the timeinterval between now and then %d", interval);
}

Does anyone have an idea what I should use to see the interval in the console output. It's not %d... I don't think I'm doing something wrong here in my function ( could be wrong of course ) , so I'm guessing it must be %d.


Solution

  • What you are looking for is %f. This is specifier to display a floating point number. NSTimeInterval is a floating point number with the unit being seconds