0
我正在用Objective-C搜索一種方式將float(audioPlayer.currentTime,例如= 3.4592)轉換爲時間字符串,分鐘和秒(03:46 )將浮點數轉換爲時間格式mm:ss
我嘗試這樣做:
static NSDateFormatter *date_formatter = nil;
if (date_formatter == nil) {
date_formatter = [[NSDateFormatter alloc] init];
[date_formatter setDateFormat:@"mm:ss"];
}
NSDate *diff = [[NSDate alloc] initWithTimeIntervalSinceNow:audioPlayer.currentTime];
NSLog(@"%@", [date_formatter stringFromDate:diff]);
...但不工作。格式是正確的,但我找不到正確初始化「差異」日期的方法。
感謝您的幫助!
哪些是audioPlayer.currentTime的單位?分,秒,毫秒? –