Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ulquiorra

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


Code:
    -(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.
 
I'm going to answer my own question here and not delete it maybe it can be usefull to someone else

it's %f 😉
 
NSTimeInterval is not an integer, it's an object.

Code:
NSDate *dateObject = [NSDate date];
NSLog(@"[B]%@[/B]", dateObject);

int dateInteger = 5;
NSLog(@"%i", dateInteger);

float dateFloat = 4.84682;
NSLog(@"%.2f", dateFloat);
 
NSTimeInterval is not an integer, it's an object.

Code:
NSDate *dateObject = [NSDate date];
NSLog(@"[B]%@[/B]", dateObject);

int dateInteger = 5;
NSLog(@"%i", dateInteger);

float dateFloat = 4.84682;
NSLog(@"%.2f", dateFloat);

NSTimeInterval is _not_ an object, it simply is a typedef of double.
 
NSTimeInterval is _not_ an object, it simply is a typedef of double.

woops, meant to write NSDate in line with my example... 😱

[edit] and that still wouldn't have answered the OP's question, which leads me to believe it's time for the first morning coffee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.