I would like to have a function that takes a week number as input and returns an array of all the NSDates that this specific week is made by.
Something like this:
-(NSArray*)allDatesInWeek:(int)weekNumber {
NSDate *today = [NSDate date];
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[calendar setFirstWeekday:2];
NSDateComponents *todayComp = [calendar components:NSYearCalendarUnit fromDate:today];
int currentyear = todayComp.year;
/* Calculate and return the date of weekNumber for current year */
}
How can this be done in a simple way?
Tested.
This assumes the first day of the week is Sunday, as stated in the NSDate API. Tweak if desired.