question concerning NSLog output %i, %d

jovany  picture jovany · Sep 11, 2009 · Viewed 11.7k times · Source

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.

Answer

ennuikiller picture ennuikiller · Sep 11, 2009

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