以下是OC代码实现将时间分钟输出为小时分钟的方法:

- (NSString *)convertMinutesToHoursAndMinutes:(NSInteger)minutes {
    NSInteger hours = minutes / 60;
    NSInteger remainingMinutes = minutes % 60;
    
    NSString *timeString = [NSString stringWithFormat:@'%ld小时%ld分钟', (long)hours, (long)remainingMinutes];
    return timeString;
}

使用示例:

NSInteger totalMinutes = 135;
NSString *convertedTime = [self convertMinutesToHoursAndMinutes:totalMinutes];
NSLog(@'%@', convertedTime);

输出结果为:2小时15分钟

iOS开发:将分钟转换为小时分钟 (OC代码)

原文地址: https://www.cveoy.top/t/topic/qeJm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录