I have two nsdatecomponent object, and I want a substract the time of my first object with the time of the seconde object.
example: DateComponentObject1 = DateComponentObject1 – DateComponentObject2
so, if I have 3 hour in DateComponentObject1 and 1 hour in DateComponentObject2, I have 2 hour at the end in the DateComponentObject1.
How I can do this?
NSCalendarobject that corresponds to the calendar used by yourNSDateComponentinstances.DateComponentObject1to anNSDatewith-[NSCalendar dateFromComponents:].DateComponentObject2by-1(because you want to subtract them from the first date).DateComponentObject2to the date object with-[NSCalendar dateByAddingComponents:toDate:options:].NSDateobject into date components with-[NSCalendar components:fromDate:].