I am new to iphone development. I have a problem. I want to convert the value of NSTimeInterval to NSString, but not success in this. Please quickly review the code below.
in .h
NSTimeInterval startTime;
NSTimeInterval stopTime;
NSTimeInterval duration;
in .m
startTime = [NSDate timeIntervalSinceReferenceDate];
stopTime = [NSDate timeIntervalSinceReferenceDate];
duration = stopTime-startTime;
NSLog(@"Duration is %@",[NSDate dateWithTimeIntervalSinceReferenceDate: duration]);
NSLog(@"Duration is %@", [NSString stringWithFormat:@"%f", duration]);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSString *time = [dateFormatter stringFromDate:duration];----> Error
[dateFormatter release];
And on one label set this line ----
[timeLabel setText:time]
but it does not work, it shows an error: incompatible type for argument 1 'stringFromDate:'
and if I comment on this line, it will show the correct duration in the console window.
Thanks for any help.
source
share