I am getting events from a Shared Google Calendar into my App using JSON. On some dates there are 2 or more events. As you can see here - the dates (found under {gd$when}, {startDate} are in a long format (2013-04-28T19:00:00.000+02:00). I would need each section to be a date in the format dd-MM-yy. Then the cell.textLabel.Text would be the Title/$t, and the cell.detailTextLabel.Text would be the time (hh:mm) from gd$when/startTime. I would only want to show those that are equal to or after todays date.
I have played around with it, to match a tutorial on raywenderlich.com. My code right now looks like this, but I haven't yet implemented it into a 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 the JSON data
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
NSArray* feed = [json valueForKeyPath:@"feed.entry"];
NSLog(@"feed: %@", feed);
for (int i=0; i<[feed count]; i++) {
NSDictionary* event = [feed objectAtIndex:i];
NSString* eventTitle = [event valueForKeyPath:@"title.$t"];
NSLog(@"Title: %@", eventTitle);
}
}
@end
If anybody can give a pointer - especially as to how I would create the sections from the date, it would be highly appreciated