Setting class level NSTimeInterval property
I am facing a weird issue. I have a class level NSTimeInterval property which I a开发者_StackOverflow社区m 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);
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);
One problem with your code is that you are using %d to print your time intervals. NSTimeInterval is a wrapper for the double type, and so requires %f to print. This will cause some funny behaviour in your log statement.
加载中,请稍侯......
精彩评论