How to add events to Kal calendar library for iOS?

909 Views Asked by At

I'v integrated Kal calendar in my app. Now i'v to add events to calendar that i receive from server as JSON and show a dot where an event is present on calendar. I've looked in example code given in github sample project but did not get any clue that how to implement data source for kal calendar? Any help would be appreciated.

1

There are 1 best solutions below

0
On BEST ANSWER

Holidays example provided on gitHub is good place to start with.here is how i did that- initialize Kal calendar in your view controller as-

kal = [[KalViewController alloc] init];
    kal.title = @"Calender";
    kal.view.frame = CGRectMake(0, 65, 320, kal.view.frame.size.height);
    [self.view addSubview:kal.view];
    kal.delegate = self;
    dataSource = [[KalCalendarDataSource alloc] init];
    kal.dataSource = dataSource;
    [kal showAndSelectDate:[NSDate date]];

and provide delegate implementation for show detail of your event

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"event selected.... ******");
    Events* event = [dataSource eventAtIndexPath:indexPath];
    EventDetailViewController* vc = [[UIStoryboard storyboardWithName:@"Main" bundle:Nil] instantiateViewControllerWithIdentifier:@"eventDetail"];
    [vc setEvent:event];
    [self.navigationController pushViewController:vc animated:YES];
}

now implement KalCalendarDataSource as given in Holidays example(HolidaySqliteDataSource) and change Holiday with your event model. There is not too much changes just model class and variable name and you will good to go.

Hope this will help.happy coading. :P