NSDate: Right way to work with time of day?

前端 未结 3 1519
梦如初夏
梦如初夏 2021-01-20 13:23

I am working with a schedule that specifies times of day, such as 10:30 AM. I do not know the dates, however. I\'m going to store these as values in a NSDictionary

3条回答
  •  萌比男神i
    2021-01-20 14:25

    You can use NSDateComponents to store only the components you need (hour and minutes for example), and then use NSCalendar dateByAddingComponents:toDate:options: to create an absolute date reference, when you need using the serialized components and a base date.

提交回复
热议问题