http://potter528.bj.bdysite.com
/**
* 將時間秒數(shù)格式化為字符串
*
* @param second 秒數(shù)
*
* @return 返回字符串
*/
+ (NSString *)getStringFormatBySeconds:(float) second{
//格式化時間,從浮點型類型轉(zhuǎn)化成"00:00"字符串
NSString *formattTime = [NSString stringWithFormat:@"%02d:%02d",(int)second / 60,(int)second % 60];
return formattTime;
}
/**
* 將字符串格式化為時間秒數(shù)
*
* @param timeString 時間字符串
*
* @return 返回float
*/
+(float)getSecondsFormatByStrings:(NSString *)timeString{
NSArray *tempArray = [timeString componentsSeparatedByString:@":"];
return [[tempArray firstObject] integerValue] * 60.0 + [[tempArray lastObject] intValue];
}