Hi
I have this code:
- (NSString*) tableView:(UITableView *)tableView titleForHeaderInSection:(int)section{
curDate = [NSDate date]; // Get current date
calendar = [NSCalendar currentCalendar];// Init calendar
comps = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSWeekCalendarUnit|NSWeekdayCalendarUnit fromDate:curDate]; // Get necessary date components
NSDateFormatter *weekFormatter = [[NSDateFormatter alloc] init];
[weekFormatter setDateFormat:@"w"];
NSString *weekDateString = [weekFormatter stringFromDate:curDate];
[weekFormatter release];
// Week days change from 1 to 7, Sunday is the 1st, Saturday - the last one.
if (tableView == monTable){
if(nextWeek == TRUE){
[comps setWeek:[weekDateString intValue] + week];
[calendar dateByAddingComponents:comps toDate:curDate options:0];
[comps setWeekday:2];
}
}
else{
[comps setWeekday:2];
}
}
if (tableView == tueTable){
if(nextWeek == TRUE){
[comps setWeek:[weekDateString intValue] + week];
[calendar dateByAddingComponents:comps toDate:curDate options:0];
[comps setWeekday:3];
}
else{
[comps setWeekday:3];
}
}
if (tableView == wedTable){
if(nextWeek == TRUE){
[comps setWeek:[weekDateString intValue] + week];
[calendar dateByAddingComponents:comps toDate:curDate options:0];
[comps setWeekday:4];
}
else{
[comps setWeekday:4];
}
}
if (tableView == thuTable){
if(nextWeek == TRUE){
[comps setWeek:[weekDateString intValue] + week];
[calendar dateByAddingComponents:comps toDate:curDate options:0];
[comps setWeekday:5];
}
else{
[comps setWeekday:5];
}
}
if (tableView == friTable){
if(nextWeek == TRUE){
[comps setWeek:[weekDateString intValue] + week];
[calendar dateByAddingComponents:comps toDate:curDate options:0];
[comps setWeekday:6];
}
else{
[comps setWeekday:6];
}
}
NSDate *tDate = [calendar dateFromComponents:comps];
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"EEE, MMM d"];
return [formatter stringFromDate:tDate];
}
So each day of the week (table) I am giving the date, but I want to add a UIDatePicker and pass the date picker date into these when its changed. Hope you can help, thanks.