objective c - UITableview sorted in sections by distinct date -
i getting events shared google calendar app using json. on dates there 2 or more events. can see here - dates (found under {gd$when}, {startdate} in long format (2013-04-28t19:00:00.000+02:00). need each section date in format dd-mm-yy. cell.textlabel.text title/$t, , cell.detailtextlabel.text time (hh:mm) gd$when/starttime. want show equal or after todays date.
i have played around it, match tutorial on raywenderlich.com. code right looks this, haven't yet implemented tableviewcontroller
#define kbgqueue dispatch_get_global_queue( dispatch_queue_priority_default, 0) #define googleurl [nsurl urlwithstring: @"http://www.google.com/calendar/feeds/kao1d80fd2u5kh7268caop11o4%40group.calendar.google.com/public/full?alt=json"] #import "viewcontroller.h" @interface viewcontroller () { iboutlet uilabel* humanreadble; iboutlet uilabel* jsonsummary; } @end @implementation viewcontroller -(void)viewdidload { [super viewdidload]; dispatch_async(kbgqueue, ^{ nsdata* data = [nsdata datawithcontentsofurl:googleurl]; [self performselectoronmainthread:@selector(fetcheddata:) withobject:data waituntildone:yes]; }); } - (void)fetcheddata:(nsdata *)responsedata { //parse out json data nserror* error; nsdictionary* json = [nsjsonserialization jsonobjectwithdata:responsedata options:kniloptions error:&error]; nsarray* feed = [json valueforkeypath:@"feed.entry"]; nslog(@"feed: %@", feed); (int i=0; i<[feed count]; i++) { nsdictionary* event = [feed objectatindex:i]; nsstring* eventtitle = [event valueforkeypath:@"title.$t"]; nslog(@"title: %@", eventtitle); } } @end
if can give pointer - how create sections date, highly appreciated
where suggestion says create number of section number of dates get, , in each section have put number of events number of rows @ each section. declare at
-(nsinteger) tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section
and after put view each header this-
- (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section { headerview=[[uiview alloc] init]; headerview.tag=section+1000; headerview.backgroundcolor=[uicolor clearcolor]; uilabel *labelinheader=[[uilabel alloc] init]; labelinheader.backgroundcolor=[uicolor clearcolor]; labelinheader.adjustsfontsizetofitwidth=yes; labelinheader.minimumscalefactor=13.00; labelinheader.textcolor=[uicolor blackcolor]; labelinheader.textalignment=nstextalignmentcenter; labelinheader.font=[uifont fontwithname:fontcenturygothicbold size:20.0]; labelinheader.frame=cgrectmake(30, 0, 229,47); labelinheader.linebreakmode=nslinebreakbywordwrapping; labelinheader.numberoflines=2; [headerview addsubview:labelinheader]; return headerview; }
hope helps.
Comments
Post a Comment