将'NSTimeInterval'(又名'double')发送到不兼容类型'id'的参数

时间:2012-10-23 11:35:34

标签: iphone compiler-errors

获取此错误,这是什么意思。

[mediaPlayTime setText:[NSString stringWithFormat:@"%@ / %@", [self formatTime:currentTime],[self formatTime:duration]]];

- (NSString*)formatTime:(float)time{
int minutes = time / 60;
int seconds = (int)time % 60;
return [NSString stringWithFormat:@"%@%d:%@%d", minutes / 10 ? [NSString stringWithFormat:@"%d", minutes / 10] : @"", minutes % 10, [NSString stringWithFormat:@"%d", seconds / 10], seconds % 10];
}

1 个答案:

答案 0 :(得分:2)

在.h

  -(NSString*)formatTime:(float)time;

的.m

  [mediaPlayTime setText:[NSString stringWithFormat:@"%@ / %@", [self formatTime:currentTime],[self formatTime:duration]]];



 - (NSString*)formatTime:(float)time{
int minutes = time / 60;
int seconds = (int)time % 60;
return [NSString stringWithFormat:@"%@%d:%@%d", minutes / 10 ? [NSString stringWithFormat:@"%d", minutes / 10] : @"", minutes % 10, [NSString stringWithFormat:@"%d", seconds / 10], seconds % 10];
}

只是微小的变化解决了这个问题。