发布网友
共1个回答
热心网友
解决方法
直接赋值:
NSTimeInterval interval = .;
NSInteger time = interval;
//time is now equal to
NSTimeInterval 是双重的所以如果你将它分配直接给 NSInteger (或 int,如果你愿意的话) 它会工作。这将切断时间精确到秒。
如果你想要舍入到最接近的秒 (而不能切断) 你可以使用圆才使分配:
NSTimeInterval interval = .;
NSInteger time = round(interval);
//time is now equal to