cocoa touch - Simplest way to loop between two NSDates on iPhone? -
What is the easiest way to loop from one date to another?
What do I need from concept:
(NSDT * date = [[initial copy] Autoreques] [compare date: enddate] & lt; 0 ; Date = [day deteriorating day: 1]) {// do stuff here}
This does not work, of course: any is not dateAddingDays: < / Code>. And even if that happens, it will leave a broad path of autoreled objects waiting for their destruction.
Here's what I thought:
- I just can not add a
NSTimeInterval
, the number of seconds in a day is different May be. - I can split it into
NSDateComponents
and add one day to the components, then add it again. But this is a long and ugly code.
So I hope someone has tried some options for this, and found a good one. Any ideas?
Set the date component of a day continuously and add it frequently:
NSCalendar * Calendar = [NSCalendar currentCalendar]; NSDateComponents * oneDay = [[NSDateComponents alloc] init]; [Single set day: 1]; (Date of Date = [[Initial Copy] Autoreques] [Compare Date: Expiry Date] & lt; = 0; Date = [Calendar Date: Baiding Compensant: One Day Date: Date Option: 0]) {NSLog (@ "% @" [% @,% @] ", Date, start, end date); }
It still leaves the mark of Autorelase objects, but dateByAddingComponents: toDate: options:
is responsible. Not sure anything about it can be done.
Comments
Post a Comment