あなたはこのようなことをすることができます:
- (NSString*)timeIntervalStringforDouble:(double)timeInterval {
NSString *intervalString=@"";
NSInteger hours = (int)floor(timeInterval/3600.0);
double remainder = timeInterval-(hours*3600);
NSInteger minutes = (int)floor(remainder/60.0);
NSInteger seconds = (int)round(remainder-(minutes*60));
NSString *temporalSegment = @"hour";
if (hours) {
if (hours>1) temporalSegment = @"hours";
intervalString = [intervalString stringByAppendingFormat:@"%d %@ ",hours,temporalSegment];
}
if (minutes || hours) {
temporalSegment = (minutes==1)? @"minute":@"minutes";
intervalString = [intervalString stringByAppendingFormat:@"%d %@ ",minutes,temporalSegment];
}
if (seconds || minutes) {
temporalSegment = (seconds==1)?@"second":@"seconds";
intervalString = [intervalString stringByAppendingFormat:@"%d %@",seconds, temporalSegment];
}
return intervalString;
}
句読点を付けて、好みに合わせてフォーマットします。