开发者

section uitable by current date?

i want the user to input a row into the table...and the row to automatical开发者_JAVA技巧ly make a table section for the day it was added and keep it in order by day..

aka the user added a row to the table today...put it under feb 22...tomorrow they will add another cell put it under create another section feb 23, and add the row to it


this will help...

today = [NSDate date];
dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM/dd/yyyy :EEEE"];
dateString = [dateFormat stringFromDate:today];
NSLog(@"date: %@", dateString);
[dateFormat release];
gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
components = [gregorian components:NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:today];

[components setDay:([components day]-([components weekday]-2))];

NSDate *lastDayofweek = [gregorian dateFromComponents:components1];
NSDateFormatter *dateFormat_last = [[NSDateFormatter alloc] init];
[dateFormat_last setDateFormat:@"MMMM d,yyyy"];
NSString *dateString_last = [dateFormat_last stringFromDate:lastDayofweek];
[dateFormat_last autorelease];
NSDate *beginningOfWeek = [gregorian dateFromComponents:components];
NSDateFormatter *dateFormat_first = [[NSDateFormatter alloc] init];
[dateFormat_first setDateFormat:@"MMMM d,yyyy"];
NSString *dateString_first = [dateFormat_first stringFromDate:beginningOfWeek];
[dateFormat_first autorelease];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜