Operation between hours

前端 未结 1 701
灰色年华
灰色年华 2021-01-29 11:55

I have 2 buttons, when I click each button a timepicker comes out and return the time in the button. I have 2 text field and 1 label. In textfield 1 I put a number that will be

相关标签:
1条回答
  • 2021-01-29 12:56

    Create NSDate objects that have the same date part, but with the time set to the times in the buttons.

    To subtract dates, use

     NSTimeInterval seconds = [date timeIntervalSinceDate:otherDate];
    

    NSTimeInterval is just a number, you can multiply it. First multiply by 60*60 to get it to hours. Then multiply it by the number on your multiplier button.

    0 讨论(0)
提交回复
热议问题