I have an NSArray filled with about 30 dates in the NSDate format,
What I need to do is create another array from this, which contains a boolean for all of the dates from the first date to the last date.
ex Array 1
1/1/11
3/1/11
5/1/11
Array 2
Yes
No
Yes
No
Yes
I need this for tapku library calendar
This is what I have so far but the i never changes
int i=0;
for (NSDate *date = [[startingDate copy] autorelease]; [date compare: endingDate] < 0;
date = [date dateByAddingTimeInterval:24 * 60 * 60] ) {
NSLog( @"%@ in [%@,%@]", date, startingDate, endingDate );
int day1 = [[NSCalendar currentCalendar] ordinalityOfUnit:NSDayCalendarUnit inUnit:NSEraCalendarUnit forDate:[eventDates objectAtIndex:i]];
int day2 = [[NSCalendar currentCalendar] ordinalityOfUnit:NSDayCalendarUnit inUnit:NSEraCalendarUnit forDate:date];
if(day1-day2==0) {
NSLog(@"yeh");
i=i+1;
//add yes to array2
} else {
NSLog(@"nah");
NSLog(@"%i",i);
//add no to array 2
}
}
I don’t think I quite understand what you want to do, but I’ll give it a try.
Suppose you have 2
NSDate‘s, call themdate1anddate2, and you want to mark any entries in an array ofNSDate‘s, call itarrayOfDates, that are between the 2NSDate‘s, or not, and store theYESorNOvalues in another array, call itboolValuesOfDates. Then try this method:This method checks the order of the 2 entered
NSDate‘s, and then compares theNSDate‘s in the array, and if they are in between, marks them with aYES, orNOotherwise. Hope that Helps!