Hello all,
I am new in iphone development. I have a issue. I want to convert a NSTimeInterval value in NSString, but not success in this. please a quick look on below code.
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 string----
[timeLabel setText:time];
but it not works it shows error: incompatible type for argument 1 of 'stringFromDate:'
and if i comment that line it shows the right duration in console window.
thanks for any help.