How to convert NSTimeInterval to int?

前端 未结 6 608
我寻月下人不归
我寻月下人不归 2021-01-03 17:47

How do I convert NSTimeInterval into an Integer value?

My TimeInterval holds the value 83.01837. I need to convert it into 83. I have googl

6条回答
  •  走了就别回头了
    2021-01-03 18:19

    According to the documentation, NSTimeInterval is just a double:

    typedef double NSTimeInterval;
    

    You can cast this to an int:

    seconds = (int) myTimeInterval;
    

    Watch out for overflows, though!

提交回复
热议问题