how do I set an existing NSDate
's time?
That is I have a date (say current date/time), but then want to set this to a specific time (e.g. 11.23am) say. What is the quickest way to do this in objective C?
I'm looking at NSCalendar
and see methods such as dateByAddingComponents:toDate:options:
, and dateFromComponents:
, but these don't seem to quite hit the mark for what I need here. For example:
dateFromComponents:
- I would have to work out all components for this to work which seems like overkill
dateByAddingComponents:toDate:options:
- I don't want to ADD in my case but rather "set" the time.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…