Search code examples
iphoneobjective-ccocoa-touchnstimeinterval

Setting class level NSTimeInterval property


I am facing a weird issue. I have a class level NSTimeInterval property which I am synthesizing and then later on try to set it with self. but it not setting it up. But similar code is working at other place. Here, is my sample code:

@property NSTimeInterval interval;
@synthesize interval;

    NSTimeInterval test = 25;
    self.interval = test;
    NSLog(@"Time=%d time1=%d", self.interval, test);

Solution

  • NSTimeInterval is actually a double and you are trying to print an integer. It's your NSLog statement that is wrong. Use %f instead.

    NSLog(@"Time=%f time1=%f", self.interval, test);